• Runtimes
  • 3.8.60: Cocos2d-x culling breaks Spine if not using cameras

Related Discussions
...

The following code from SkeletonRenderer broke our game:

#if CC_USE_CULLING
const Camera* camera = Camera::getVisitingCamera();
const cocos2d::Rect brect = computeBoundingRect(worldCoords, coordCount / 2);
_boundingRect = brect;

if (camera && cullRectangle(transform, brect, *camera))
{
   VLA_FREE(worldCoords);
   return;
}
#endif

This assumes that the developer is using Cocos's camera system. The default camera, we think, is some tiny area in the center of the screen. As we manage our views manually, we were perplexed to see some spines rendering, not rendering, and flashing in and out of existence arbitrarily. We only accidentally stumbled on the solution by disabling culling entirely in Cocos. Knowing this, we have decided to comment-out this part of the skeleton renderer instead.

Are there any other areas of the runtime we need to know about with regards to culling?

As far as a proposal for a fix, I don't have one. We might be the only developer who doesn't use cameras for all we know. It certainly wasn't easy to debug, as things were technically working as intended. Either way it's a change from 3.7 and I'm posting this for posterity.

Thanks for reporting. We have an issue on the tracker for this [cocos2dx] Broken culling when using 2d projection · #1445

I'll make the culling of Spine models optional instead of the default behaviour. The current implementation assumes a perspective projection matrix is provided, which doesn't always hold.