Skip to content

Commit c651aa7

Browse files
committed
-
1 parent 79637af commit c651aa7

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

src/MapRenderer.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,18 @@ void MapRenderer::DrawGameObject(RenderView* renderview, GameObject* gameObject)
125125
gameObject->PreDrawFrame();
126126

127127
// detect if gameobject is visible on screen
128-
static glm::vec2 points[2];
129-
gameObject->mDrawSprite.GetMaxRectPoints(points);
130-
131-
static cxx::aabbox_t bounds;
132-
bounds.clear();
133-
bounds.extend(points[0].x, 1.0f, points[0].y);
134-
bounds.extend(points[1].x, 1.0f, points[1].y);
135-
136-
if (renderview->mCamera.mFrustum.contains(bounds))
128+
const glm::vec2 spritePosition = (gameObject->mDrawSprite.mPosition + gameObject->mDrawSprite.mOrigin);
129+
float maxdistance = Convert::MapUnitsToMeters(10.0f); // todo: magic numbers
130+
if (fabs(renderview->mCamera.mPosition.x - spritePosition.x) > maxdistance ||
131+
fabs(renderview->mCamera.mPosition.z - spritePosition.y) > maxdistance)
132+
{
133+
// skip
134+
}
135+
else
137136
{
138137
mSpriteBatch.DrawSprite(gameObject->mDrawSprite);
139-
++mRenderStats.mSpritesDrawnCount;
140138

139+
++mRenderStats.mSpritesDrawnCount;
141140
gameObject->mLastRenderFrame = mRenderStats.mRenderFramesCounter;
142141
}
143142
}

src/PhysicsManager.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ void PhysicsManager::UpdateFrame()
9494
ProcessSimulationStep();
9595
mSimulationTimeAccumulator -= mSimulationStepTime;
9696
}
97-
98-
if (mSimulationTimeAccumulator > 0.0f)
99-
{
100-
ProcessSimulationStep();
101-
mSimulationTimeAccumulator = 0.0;
102-
}
103-
10497
ProcessInterpolation();
10598
}
10699

0 commit comments

Comments
 (0)