void SaveEntityAsAction::Redo() { if(!sc2Path.IsEmpty() && sc2Path.IsEqualToExtension(".sc2") && NULL != entities && entities->Size() > 0) { DAVA::Scene *scene = new DAVA::Scene(); Vector3 oldZero = entities->GetCommonZeroPos(); for(size_t i = 0; i < entities->Size(); ++i) { DAVA::Entity *entity = entities->GetEntity(i); DAVA::Entity *clone = entity->Clone(); Vector3 offset = clone->GetLocalTransform().GetTranslationVector() - oldZero; Matrix4 newLocalTransform = clone->GetLocalTransform(); newLocalTransform.SetTranslationVector(offset); clone->SetLocalTransform(newLocalTransform); DAVA::KeyedArchive *props = GetCustomPropertiesArchieve(clone); if(props) { props->DeleteKey(ResourceEditor::EDITOR_REFERENCE_TO_OWNER); } scene->AddNode(clone); } scene->Save(sc2Path); scene->Release(); } }
void QtPropertyDataIntrospection::BakeTransform() { QtPropertyDataIntrospection * renderComponentProperty = static_cast<QtPropertyDataIntrospection*>(parent); DAVA::Entity * entity = (static_cast<DAVA::RenderComponent*>(renderComponentProperty->object))->GetEntity(); DAVA::RenderObject * ro = static_cast<DAVA::RenderObject*>(object); ro->BakeTransform(entity->GetLocalTransform()); entity->SetLocalTransform(DAVA::Matrix4::IDENTITY); }