Merge pull request #192 from lvlonggame/frustum

Frustum
This commit is contained in:
XiaoYang 2014-12-25 14:28:50 +07:00
commit 8ffe37d6dc
4 changed files with 4 additions and 108 deletions

View File

@ -259,7 +259,7 @@ void Camera::enableFrustumCulling(bool enalbe, bool clipZ)
_frustum.setClipZ(clipZ);
}
bool Camera::isVisibleInFrustum(const AABB& aabb) const
bool Camera::isVisibleInFrustum(const AABB* aabb) const
{
if (_enableFrustumCulling)
{
@ -268,7 +268,7 @@ bool Camera::isVisibleInFrustum(const AABB& aabb) const
_frustum.initFrustum(this);
_frustumDirty = false;
}
return !_frustum.isOutOfFrustum(aabb);
return !_frustum.isOutOfFrustum(*aabb);
}
return true;
}

View File

@ -144,7 +144,7 @@ public:
/**
* Is this aabb visible in frustum
*/
bool isVisibleInFrustum(const AABB& aabb)const;
bool isVisibleInFrustum(const AABB* aabb)const;
//override
virtual void onEnter() override;

View File

@ -538,7 +538,7 @@ static Texture2D * getDummyTexture()
void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
// camera clipping
if(!Camera::getVisitingCamera()->isVisibleInFrustum(this->getAABB()))
if(!Camera::getVisitingCamera()->isVisibleInFrustum(&this->getAABB()))
return;
if (_skeleton)

View File

@ -60772,58 +60772,6 @@ int lua_cocos2dx_Camera_getType(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Camera_enableFrustumCulling(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Camera* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Camera",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Camera*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Camera_enableFrustumCulling'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
bool arg0;
bool arg1;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Camera:enableFrustumCulling");
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.Camera:enableFrustumCulling");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Camera_enableFrustumCulling'", nullptr);
return 0;
}
cobj->enableFrustumCulling(arg0, arg1);
return 0;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Camera:enableFrustumCulling",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Camera_enableFrustumCulling'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Camera_lookAt(lua_State* tolua_S)
{
int argc = 0;
@ -60876,56 +60824,6 @@ int lua_cocos2dx_Camera_lookAt(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Camera_isVisibleInFrustum(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Camera* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Camera",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Camera*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Camera_isVisibleInFrustum'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::AABB arg0;
ok &= luaval_to_object<cocos2d::AABB>(tolua_S, 2, "cc.AABB",&arg0);
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Camera_isVisibleInFrustum'", nullptr);
return 0;
}
bool ret = cobj->isVisibleInFrustum(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Camera:isVisibleInFrustum",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Camera_isVisibleInFrustum'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Camera_setCameraFlag(lua_State* tolua_S)
{
int argc = 0;
@ -61144,9 +61042,7 @@ int lua_register_cocos2dx_Camera(lua_State* tolua_S)
tolua_function(tolua_S,"getViewMatrix",lua_cocos2dx_Camera_getViewMatrix);
tolua_function(tolua_S,"getCameraFlag",lua_cocos2dx_Camera_getCameraFlag);
tolua_function(tolua_S,"getType",lua_cocos2dx_Camera_getType);
tolua_function(tolua_S,"enableFrustumCulling",lua_cocos2dx_Camera_enableFrustumCulling);
tolua_function(tolua_S,"lookAt",lua_cocos2dx_Camera_lookAt);
tolua_function(tolua_S,"isVisibleInFrustum",lua_cocos2dx_Camera_isVisibleInFrustum);
tolua_function(tolua_S,"setCameraFlag",lua_cocos2dx_Camera_setCameraFlag);
tolua_function(tolua_S,"create", lua_cocos2dx_Camera_create);
tolua_function(tolua_S,"createPerspective", lua_cocos2dx_Camera_createPerspective);