render parity unit J: 40250 automatic sight range in CPythonApplication::Process
Process now runs 40250's render-time / face-count block and sets view distance set 0 each frame (25600 under 5000 faces, else scaled by render time, or the forced range). SetForceSightRange and SkipRenderBuffering are ported from stubs; the invented SetCursorPosition in UpdateGame is removed. Port-map boilerplate notes replaced; Destroy recorded as DIVERGENT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0e8a1574cb
commit
dda885a17a
@@ -70,6 +70,8 @@ float CPythonApplication::GetGlobalTime() { return CTimer::Instance().GetCurrent
|
||||
// PORT: read straight from the timer, as GetGlobalTime above.
|
||||
float CPythonApplication::GetGlobalElapsedTime() { return CTimer::Instance().GetElapsedSecond(); }
|
||||
static bool s_isFrameSkipDisable = false;
|
||||
// m_iForceSightRange (the 40250 constructor sets -1: automatic sight range).
|
||||
static int s_iForceSightRange = -1;
|
||||
void CPythonApplication::SetFrameSkip(bool isEnable) { s_isFrameSkipDisable = !isEnable; }
|
||||
// PORT: 40250 creates the Win32 window, the D3D8 device, cursors, sound, keyboard, the net device,
|
||||
// fonts and the IME here. The Godot window and its canvas already exist when the host starts the
|
||||
@@ -261,7 +263,6 @@ void CPythonApplication::UpdateGame()
|
||||
|
||||
s.SetPerspective(30.0f,fAspect, 100.0f, fFarClip);
|
||||
s.BuildViewFrustum();
|
||||
s.SetCursorPosition(ptMouse.x, ptMouse.y, UI::CWindowManager::Instance().GetScreenWidth(), UI::CWindowManager::Instance().GetScreenHeight());
|
||||
}
|
||||
|
||||
TPixelPosition kPPosMainActor;
|
||||
@@ -315,8 +316,11 @@ bool CPythonApplication::Process()
|
||||
if (IsNativeTerrainRenderEnabled())
|
||||
CGrannyMaterial::TranslateSpecularMatrix(g_specularSpd, g_specularSpd, 0.0f);
|
||||
|
||||
// PORT: the render block without the lost-device restore, ClearDepthBuffer, Show and the render-time
|
||||
// statistics (Godot clears and presents the frame). The frame's UI and 3D command lists restart here.
|
||||
// PORT: the render block without the lost-device restore, ClearDepthBuffer and Show (Godot clears
|
||||
// and presents the frame), and without the !IsActive() SkipRenderBuffering(3000): the host has no
|
||||
// Win32 activation (CMSWindow::IsActive is a stub). The frame's UI and 3D command lists restart here.
|
||||
// 40250 PythonApplication.cpp:681.
|
||||
DWORD dwRenderStartTime = ELTimer_GetMSec();
|
||||
CCullingManager::Instance().Update();
|
||||
UIRenderBeginFrame();
|
||||
Render3DBeginFrame();
|
||||
@@ -336,6 +340,93 @@ bool CPythonApplication::Process()
|
||||
}
|
||||
|
||||
rkGraphic.End();
|
||||
|
||||
// 40250 PythonApplication.cpp:741-842 (render time, face count, automatic sight range), minus the
|
||||
// per-second FPS/face counters and the windowed dwBufRenderTime rounding, whose result 40250 never
|
||||
// uses (its Sleep is commented out).
|
||||
DWORD dwRenderEndTime = ELTimer_GetMSec();
|
||||
|
||||
static DWORD s_dwRenderCheckTime = dwRenderEndTime;
|
||||
static DWORD s_dwRenderRangeTime = 0;
|
||||
static DWORD s_dwRenderRangeFrame = 0;
|
||||
|
||||
m_dwCurRenderTime = dwRenderEndTime - dwRenderStartTime;
|
||||
s_dwRenderRangeTime += m_dwCurRenderTime;
|
||||
++s_dwRenderRangeFrame;
|
||||
|
||||
if (dwRenderEndTime-s_dwRenderCheckTime>1000)
|
||||
{
|
||||
m_fAveRenderTime=float(double(s_dwRenderRangeTime)/double(s_dwRenderRangeFrame));
|
||||
|
||||
s_dwRenderCheckTime=ELTimer_GetMSec();
|
||||
s_dwRenderRangeTime=0;
|
||||
s_dwRenderRangeFrame=0;
|
||||
}
|
||||
|
||||
DWORD dwCurFaceCount=rkGraphic.GetFaceCount();
|
||||
rkGraphic.ResetFaceCount();
|
||||
|
||||
if (dwCurFaceCount > 5000)
|
||||
{
|
||||
// 프레임 완충 처리
|
||||
if (dwRenderEndTime > m_dwBufSleepSkipTime)
|
||||
{
|
||||
static float s_fBufRenderTime = 0.0f;
|
||||
|
||||
float fCurRenderTime = m_dwCurRenderTime;
|
||||
|
||||
if (fCurRenderTime > s_fBufRenderTime)
|
||||
{
|
||||
float fRatio = fMAX(0.5f, (fCurRenderTime - s_fBufRenderTime) / 30.0f);
|
||||
s_fBufRenderTime = (s_fBufRenderTime * (100.0f - fRatio) + (fCurRenderTime + 5) * fRatio) / 100.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float fRatio = 0.5f;
|
||||
s_fBufRenderTime = (s_fBufRenderTime * (100.0f - fRatio) + fCurRenderTime * fRatio) / 100.0f;
|
||||
}
|
||||
|
||||
// 한계치를 정한다
|
||||
if (s_fBufRenderTime > 100.0f)
|
||||
s_fBufRenderTime = 100.0f;
|
||||
|
||||
m_fAveRenderTime=s_fBufRenderTime;
|
||||
}
|
||||
|
||||
m_dwFaceAccCount += dwCurFaceCount;
|
||||
m_dwFaceAccTime += m_dwCurRenderTime;
|
||||
|
||||
// PORT: recording a frame can take under 1 ms, so the integer division is guarded (40250's
|
||||
// D3D frame never took 0 ms).
|
||||
if (m_dwFaceAccTime)
|
||||
m_fFaceSpd=(m_dwFaceAccCount/m_dwFaceAccTime);
|
||||
|
||||
// 거리 자동 조절
|
||||
if (-1 == s_iForceSightRange)
|
||||
{
|
||||
static float s_fAveRenderTime = 16.0f;
|
||||
float fRatio=0.3f;
|
||||
s_fAveRenderTime=(s_fAveRenderTime*(100.0f-fRatio)+max(16.0f, m_dwCurRenderTime)*fRatio)/100.0f;
|
||||
|
||||
|
||||
float fFar=25600.0f;
|
||||
float fNear=MIN_FOG;
|
||||
double dbAvePow=double(1000.0f/s_fAveRenderTime);
|
||||
double dbMaxPow=60.0;
|
||||
float fDistance=max(fNear+(fFar-fNear)*(dbAvePow)/dbMaxPow, fNear);
|
||||
CPythonBackground::Instance().SetViewDistanceSet(0, fDistance);
|
||||
}
|
||||
// 거리 강제 설정시
|
||||
else
|
||||
{
|
||||
CPythonBackground::Instance().SetViewDistanceSet(0, float(s_iForceSightRange));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 10000 폴리곤 보다 적을때는 가장 멀리 보이게 한다
|
||||
CPythonBackground::Instance().SetViewDistanceSet(0, 25600.0f);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -483,7 +574,11 @@ time_t CPythonApplication::GetServerTime() { return GetPlatformServerTime(); }
|
||||
time_t CPythonApplication::GetServerTimeStamp() { return GetPlatformServerTimeStamp(); }
|
||||
void CPythonApplication::SetConnectData(const char*, int) { MT_PLATFORM_STUB(); }
|
||||
void CPythonApplication::GetConnectData(std::string& ip, int& port) { MT_PLATFORM_STUB(); ip.clear(); port = 0; }
|
||||
void CPythonApplication::SetForceSightRange(int) { MT_PLATFORM_STUB(); }
|
||||
// 40250 PythonApplication.cpp:1377.
|
||||
void CPythonApplication::SetForceSightRange(int iRange)
|
||||
{
|
||||
s_iForceSightRange = iRange;
|
||||
}
|
||||
|
||||
int CPythonApplication::CheckDeviceState()
|
||||
{
|
||||
@@ -506,9 +601,10 @@ void CPythonApplication::NotifyHack(const char* c_szFormat, ...)
|
||||
CPythonNetworkStream::Instance().NotifyHack(szBuf);
|
||||
}
|
||||
|
||||
// 40250 PythonApplication.cpp:394
|
||||
void CPythonApplication::SkipRenderBuffering(DWORD dwSleepMSec)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_dwBufSleepSkipTime=ELTimer_GetMSec()+dwSleepMSec;
|
||||
}
|
||||
|
||||
void CPythonApplication::UpdateClientRect()
|
||||
|
||||
Reference in New Issue
Block a user