void Scene::__addObject( const Object3D::Ptr& object ) { if ( !object ) return; detail::Add objectAdd( *this, object ); object->visit( objectAdd ); dispatchEvent( Event("objectAdded", object.get()) ); object->dispatchEvent( Event("addedToScene", this) ); for ( auto& child : object->children ) { __addObject( child ); } }
void Scene::__addObject(Object * object) { if (dynamic_cast<Light *>(object)) { lights.push_back(object); } else if (!dynamic_cast<Camera *>(object)) { objects.push_back(object); objectsAdded.push_back(object); objectsRemoved.erase(std::remove(objectsRemoved.begin(), objectsRemoved.end(), object), objectsRemoved.end()); } for (std::vector<Object *>::iterator it = object->children.begin(), end = object->children.end(); it != end; ++it) __addObject(*it); }