ScenePtr CreateScene(const char* name){
		if (!ValidCStringLength(name)){
			Logger::Log(FB_ERROR_LOG_ARG, "invalid arg");
			return 0;
		}

		auto it = mScenes.find(name);
		if (it != mScenes.end()){
			auto scene = it->second.lock();
			if (scene)
				return scene;
		}
		auto scene = Scene::Create(name);
		mScenes[name] = scene;
		if (mMainScene.expired())
			mMainScene = scene;
		return scene;
	}
Exemplo n.º 2
0
void Scene::Linkage::setLeaf(const ScenePtr& root, SceneWeakPtr& newLeaf, bool left) {

	ScenePtr target = root;

	while (true) {
		(left ? target->linkage.leftLeaf : target->linkage.rightLeaf) = newLeaf;

		if (newLeaf.expired()) {
			newLeaf = target;
		}

		if (target->linkage.hasParent()
			&& (left ?
				target->linkage.getParent()->linkage.getFirstChild() :
				target->linkage.getParent()->linkage.getLastChild()) == target) {
			target = target->linkage.getParent();
		}
		else {
			break;
		}
	}

}