From 5574eccebd16ae38a2a21ed202d1f9d1ba8f67a4 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 26 Dec 2012 20:58:02 +0100 Subject: Engine optimization - rewritten model management - new class CModelManager - rewritten engine object structure in CEngine - created shared model data instead of separate objects per each model instance - minor refactoring --- src/object/motion/motionworm.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/object/motion/motionworm.cpp') diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp index 2401ebd..b53b865 100644 --- a/src/object/motion/motionworm.cpp +++ b/src/object/motion/motionworm.cpp @@ -19,7 +19,7 @@ #include "app/app.h" -#include "graphics/engine/modelfile.h" +#include "graphics/engine/modelmanager.h" #include "graphics/engine/particle.h" #include "graphics/engine/terrain.h" @@ -81,13 +81,10 @@ void CMotionWorm::DeleteObject(bool bAll) bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, float power) { - Gfx::CModelFile* pModFile; int rank, i; float px; -// if ( m_engine->GetRestCreate() < 2+WORM_PART+1 ) return false; - - pModFile = new Gfx::CModelFile(m_iMan); + Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer(); m_object->SetType(type); @@ -95,8 +92,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, rank = m_engine->CreateObject(); m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object m_object->SetObjectRank(0, rank); - pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm0.mod")); // there is no purpose! - pModFile->CreateEngineObject(rank); + modelManager->AddModelReference("worm0.mod", false, rank); // there is no purpose! m_object->SetPosition(0, pos); m_object->SetAngleY(0, angle); @@ -111,8 +107,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); m_object->SetObjectRank(1, rank); m_object->SetObjectParent(1, 0); - pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm1.mod")); - pModFile->CreateEngineObject(rank); + modelManager->AddModelReference("worm1.mod", false, rank); m_object->SetPosition(1, Math::Vector(px, 0.0f, 0.0f)); px -= 1.0f; @@ -123,8 +118,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); m_object->SetObjectRank(2+i, rank); m_object->SetObjectParent(2+i, 0); - pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm2.mod")); - pModFile->CreateEngineObject(rank); + modelManager->AddModelReference("worm2.mod", false, rank); m_object->SetPosition(2+i, Math::Vector(px, 0.0f, 0.0f)); px -= 1.0f; } @@ -134,8 +128,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); m_object->SetObjectRank(2+WORM_PART, rank); m_object->SetObjectParent(2+WORM_PART, 0); - pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm3.mod")); - pModFile->CreateEngineObject(rank); + modelManager->AddModelReference("worm3.mod", false, rank); m_object->SetPosition(2+WORM_PART, Math::Vector(px, 0.0f, 0.0f)); m_object->CreateShadowCircle(0.0f, 1.0f, Gfx::ENG_SHADOW_WORM); @@ -148,7 +141,6 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, m_engine->LoadAllTextures(); - delete pModFile; return true; } -- cgit v1.2.3-1-g7c22 From 2ebe1fbcb68957bf1d374ffc5dc818dd706c72a7 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Fri, 28 Dec 2012 13:23:49 +0100 Subject: Fixed spider and worm model loading --- src/object/motion/motionworm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/object/motion/motionworm.cpp') diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp index b53b865..f32765d 100644 --- a/src/object/motion/motionworm.cpp +++ b/src/object/motion/motionworm.cpp @@ -92,7 +92,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, rank = m_engine->CreateObject(); m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object m_object->SetObjectRank(0, rank); - modelManager->AddModelReference("worm0.mod", false, rank); // there is no purpose! + // This is an "empty" object, without triangles m_object->SetPosition(0, pos); m_object->SetAngleY(0, angle); -- cgit v1.2.3-1-g7c22 From 001d37b257b126dd6ef1dced70f94ff3d2806d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Dziwi=C5=84ski?= Date: Sat, 16 Feb 2013 22:37:43 +0100 Subject: CInstanceManager refactoring * removed classes managed by CInstanceManager except for CObject, CPyro, CBrain and CPhysics because of dependencies * refactored instance searching to use existing singleton instances of CApplication, CEngine and CRobotMain and calling their getter functions --- src/object/motion/motionworm.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/object/motion/motionworm.cpp') diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp index f32765d..ee555a8 100644 --- a/src/object/motion/motionworm.cpp +++ b/src/object/motion/motionworm.cpp @@ -42,8 +42,7 @@ const int WORM_PART = 7; // number of parts of a worm // Object's constructor. -CMotionWorm::CMotionWorm(CInstanceManager* iMan, CObject* object) - : CMotion(iMan, object) +CMotionWorm::CMotionWorm(CObject* object) : CMotion(object) { m_timeUp = 18.0f; m_timeDown = 18.0f; -- cgit v1.2.3-1-g7c22