Skip to content

Commit

Permalink
Checking for visibility every frame and using camera position in chec…
Browse files Browse the repository at this point in the history
…kVisibility
  • Loading branch information
elnormous committed Jun 18, 2015
1 parent 7b569ba commit 8f2e35c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cocos/2d/CCLabel.cpp
Expand Up @@ -898,7 +898,7 @@ void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
// Don't do calculate the culling if the transform was not updated
bool transformUpdated = flags & FLAGS_TRANSFORM_DIRTY;
#if CC_USE_CULLING
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
_insideBounds = renderer->checkVisibility(transform, _contentSize);

if(_insideBounds)
#endif
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCSprite.cpp
Expand Up @@ -589,7 +589,7 @@ void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
#if CC_USE_CULLING
// Don't do calculate the culling if the transform was not updated
_insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
_insideBounds = renderer->checkVisibility(transform, _contentSize);

if(_insideBounds)
#endif
Expand Down
4 changes: 2 additions & 2 deletions cocos/renderer/CCRenderer.cpp
Expand Up @@ -983,8 +983,8 @@ bool Renderer::checkVisibility(const Mat4 &transform, const Size &size)
transform.transformVector(v4local, &v4world);

// center of screen is (0,0)
v4world.x -= screen_half.width;
v4world.y -= screen_half.height;
v4world.x -= scene->_defaultCamera->getPosition().x;
v4world.y -= scene->_defaultCamera->getPosition().y;

// convert content size to world coordinates
float wshw = std::max(fabsf(hSizeX * transform.m[0] + hSizeY * transform.m[4]), fabsf(hSizeX * transform.m[0] - hSizeY * transform.m[4]));
Expand Down

0 comments on commit 8f2e35c

Please sign in to comment.