bool EditorUtility::calculateMeshBounds(const HSceneObject& object, AABox& bounds) { bounds = AABox(Vector3::ZERO, Vector3::ZERO); if (object.isDestroyed()) return false; bool foundOne = false; const Vector<HComponent>& components = object->getComponents(); for (auto& component : components) { Bounds curBounds; if (component->calculateBounds(curBounds)) { if (!foundOne) { bounds = curBounds.getBox(); foundOne = true; } else bounds.merge(curBounds.getBox()); } else { if (!foundOne) bounds = curBounds.getBox(); } } return foundOne; }
void ScriptGUIWidget::internal_UpdateTransform(ScriptGUIWidget* thisPtr, ScriptSceneObject* parent) { HSceneObject parentSO = parent->getNativeSceneObject(); SPtr<GUIWidget> widget = thisPtr->getInternal(); if (!parentSO.isDestroyed() && widget != nullptr) { widget->_updateTransform(parentSO); widget->_updateRT(); if (parentSO->getActive() != widget->getIsActive()) widget->setIsActive(parentSO->getActive()); } }
void ScriptLight::internal_updateTransform(ScriptLight* thisPtr, ScriptSceneObject* parent) { HSceneObject parentSO = parent->getNativeSceneObject(); if (!parentSO.isDestroyed()) { thisPtr->getInternal()->_updateTransform(parentSO); if (parentSO->getActive() != thisPtr->getInternal()->getIsActive()) { thisPtr->getInternal()->setIsActive(parentSO->getActive()); } } }
void ScriptSerializedSceneObject::internal_Restore(ScriptSerializedSceneObject* thisPtr) { HSceneObject sceneObj = thisPtr->mSO; if (sceneObj.isDestroyed()) return; HSceneObject parent = sceneObj->getParent(); UINT32 numChildren = sceneObj->getNumChildren(); HSceneObject* children = nullptr; if (!thisPtr->mRecordHierarchy) { children = bs_stack_new<HSceneObject>(numChildren); for (UINT32 i = 0; i < numChildren; i++) { HSceneObject child = sceneObj->getChild(i); children[i] = child; child->setParent(HSceneObject()); } } sceneObj->destroy(true); GameObjectManager::instance().setDeserializationMode(GODM_RestoreExternal | GODM_UseNewIds); MemorySerializer serializer; SPtr<SceneObject> restored = std::static_pointer_cast<SceneObject>( serializer.decode(thisPtr->mSerializedObject, thisPtr->mSerializedObjectSize)); EditorUtility::restoreIds(restored->getHandle(), thisPtr->mSceneObjectProxy); restored->setParent(parent); if (!thisPtr->mRecordHierarchy) { for (UINT32 i = 0; i < numChildren; i++) children[i]->setParent(restored->getHandle()); bs_stack_delete(children, numChildren); } restored->_instantiate(); }