2d cull only for default camera

This commit is contained in:
yangxiao 2014-08-27 12:09:23 +08:00
Родитель 31f406bbdd
Коммит 26f7345693
3 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -193,6 +193,8 @@ void Scene::addChildToPhysicsWorld(Node* child)
}
}
#endif
void Scene::onProjectionChanged(EventCustom* event)
{
if (_defaultCamera)
@ -201,6 +203,4 @@ void Scene::onProjectionChanged(EventCustom* event)
}
}
#endif
NS_CC_END

Просмотреть файл

@ -83,6 +83,7 @@ protected:
friend class SpriteBatchNode;
friend class Camera;
friend class Director;
friend class Renderer;
std::vector<Camera*> _cameras; //weak ref to Camera
Camera* _defaultCamera; //weak ref, default camera created by scene, _cameras[0], Caution that the default camera can not be added to _cameras before onEnter is called

Просмотреть файл

@ -39,6 +39,8 @@
#include "base/CCEventDispatcher.h"
#include "base/CCEventListenerCustom.h"
#include "base/CCEventType.h"
#include "base/CCCamera.h"
#include "2d/CCScene.h"
NS_CC_BEGIN
@ -549,6 +551,11 @@ void Renderer::flush3D()
bool Renderer::checkVisibility(const Mat4 &transform, const Size &size)
{
auto scene = Director::getInstance()->getRunningScene();
// only cull the default camera. The culling algorithm is valid for default camera.
if (scene->_defaultCamera != Camera::getVisitingCamera())
return true;
// half size of the screen
Size screen_half = Director::getInstance()->getWinSize();
screen_half.width /= 2;