Skip to content

refactor CCScene #19767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions cocos/2d/CCScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,16 @@ THE SOFTWARE.
NS_CC_BEGIN

Scene::Scene()
: _defaultCamera(Camera::create())
, _event(Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_PROJECTION_CHANGED, std::bind(&Scene::onProjectionChanged, this, std::placeholders::_1)))
{
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
_physics3DWorld = nullptr;
_physics3dDebugCamera = nullptr;
#endif
#if CC_USE_NAVMESH
_navMesh = nullptr;
_navMeshDebugCamera = nullptr;
#endif
#if CC_USE_PHYSICS
_physicsWorld = nullptr;
#endif
_ignoreAnchorPointForPosition = true;
setAnchorPoint(Vec2(0.5f, 0.5f));

_cameraOrderDirty = true;

//create default camera
_defaultCamera = Camera::create();

addChild(_defaultCamera);

_event = Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_PROJECTION_CHANGED, std::bind(&Scene::onProjectionChanged, this, std::placeholders::_1));
_event->retain();

Camera::_visitingCamera = nullptr;
Expand Down
16 changes: 8 additions & 8 deletions cocos/2d/CCScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ class CC_DLL Scene : public Node
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
bool _cameraOrderDirty; // order is dirty, need sort
EventListenerCustom* _event;
Camera* _defaultCamera = nullptr; //weak ref, default camera created by scene, _cameras[0], Caution that the default camera can not be added to _cameras before onEnter is called
bool _cameraOrderDirty = true; // order is dirty, need sort
EventListenerCustom* _event = nullptr;

std::vector<BaseLight *> _lights;

Expand Down Expand Up @@ -201,12 +201,12 @@ class CC_DLL Scene : public Node
void addChildToPhysicsWorld(Node* child);

#if CC_USE_PHYSICS
PhysicsWorld* _physicsWorld;
PhysicsWorld* _physicsWorld = nullptr;
#endif

#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
Physics3DWorld* _physics3DWorld;
Camera* _physics3dDebugCamera; //
Physics3DWorld* _physics3DWorld = nullptr;
Camera* _physics3dDebugCamera = nullptr;
#endif
#endif // (CC_USE_PHYSICS || CC_USE_3D_PHYSICS)

Expand All @@ -222,8 +222,8 @@ class CC_DLL Scene : public Node
void setNavMeshDebugCamera(Camera *camera);

protected:
NavMesh* _navMesh;
Camera * _navMeshDebugCamera;
NavMesh* _navMesh = nullptr;
Camera * _navMeshDebugCamera = nullptr;
#endif

#if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION) || CC_USE_NAVMESH)
Expand Down