Skip to content

Commit

Permalink
UPBGE: Fix lod update using always the scene active camera.
Browse files Browse the repository at this point in the history
Previously lod update was always using the scene active camera, but this camera
don't have a meaning when the user use multiple viewports.

To fix this issue the function KX_Scene::UpdateObjectLod accept as argument the
current camera used for rendering.
  • Loading branch information
panzergame committed Dec 22, 2016
1 parent 310aaf1 commit 26e7a92
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/gameengine/Ketsji/KX_KetsjiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene *scene, KX_Camera *cam, unsigned shor
scene->CalculateVisibleMeshes(m_rasterizer, cam);

// update levels of detail
scene->UpdateObjectLods();
scene->UpdateObjectLods(cam);

m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
Expand Down
9 changes: 3 additions & 6 deletions source/gameengine/Ketsji/KX_Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,13 +1715,10 @@ void KX_Scene::RenderCubeMaps(RAS_IRasterizer *rasty)
m_cubeMapManager->Render(rasty);
}

void KX_Scene::UpdateObjectLods()
void KX_Scene::UpdateObjectLods(KX_Camera *cam)
{
if (!m_active_camera)
return;

const MT_Vector3& cam_pos = m_active_camera->NodeGetWorldPosition();
const float lodfactor = m_active_camera->GetLodDistanceFactor();
const MT_Vector3& cam_pos = cam->NodeGetWorldPosition();
const float lodfactor = cam->GetLodDistanceFactor();

for (CListValue::iterator<KX_GameObject> it = m_objectlist->GetBegin(), end = m_objectlist->GetEnd(); it != end; ++it) {
KX_GameObject *gameobj = *it;
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Ketsji/KX_Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class KX_Scene : public CValue, public SCA_IScene
void Resume();

/// Update the mesh for objects based on level of detail settings
void UpdateObjectLods();
void UpdateObjectLods(KX_Camera *cam);

// LoD Hysteresis functions
void SetLodHysteresis(bool active);
Expand Down

0 comments on commit 26e7a92

Please sign in to comment.