mikymod пре 12 година
родитељ
комит
2712a79e35
2 измењених фајлова са 9 додато и 10 уклоњено
  1. 8 7
      engine/World.cpp
  2. 1 3
      engine/World.h

+ 8 - 7
engine/World.cpp

@@ -41,6 +41,7 @@ World::World()
 	, m_camera_pool(default_allocator(), MAX_CAMERAS, sizeof(Camera), CE_ALIGNOF(Camera))
 	, m_unit_to_sound(default_allocator())
 {
+	create_actor(0, ActorType::DYNAMIC);
 }
 
 //-----------------------------------------------------------------------------
@@ -52,11 +53,8 @@ UnitId World::spawn_unit(const char* name, const Vector3& pos, const Quaternion&
 	// Create a new scene graph
 	SceneGraph* sg = m_scenegraph_manager.create_scene_graph();
 
-	// Create a new physics graph
-	PhysicsGraph* pg = m_physicsgraph_manager.create_physics_graph();
-
 	// Allocate memory for unit
-	Unit* unit = CE_NEW(m_unit_pool, Unit)(*this, *sg, *pg, ur, Matrix4x4(rot, pos));
+	Unit* unit = CE_NEW(m_unit_pool, Unit)(*this, *sg, ur, Matrix4x4(rot, pos));
 
 	// Create Id for the unit
 	const UnitId unit_id = m_units.create(unit);
@@ -137,10 +135,13 @@ Actor* World::lookup_actor(ActorId actor)
 }
 
 //-----------------------------------------------------------------------------
-void World::update(float /*dt*/)
+void World::update(float dt)
 {
 	// Update scene graphs
 	m_scenegraph_manager.update();
+
+	// Update physics world
+	m_physics_world.update(dt);
 }
 
 //-----------------------------------------------------------------------------
@@ -202,9 +203,9 @@ void World::destroy_sprite(SpriteId id)
 }
 
 //-----------------------------------------------------------------------------
-ActorId	World::create_actor(PhysicsGraph& pg, int32_t node, ActorType::Enum type)
+ActorId	World::create_actor(int32_t node, ActorType::Enum type)
 {
-	return m_physics_world.create_actor(pg, node, type);
+	return m_physics_world.create_actor(node, type);
 }
 
 //-----------------------------------------------------------------------------

+ 1 - 3
engine/World.h

@@ -38,7 +38,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "SoundRenderer.h"
 #include "PoolAllocator.h"
 #include "SceneGraphManager.h"
-#include "PhysicsGraphManager.h"
 #include "PhysicsTypes.h"
 
 namespace crown
@@ -112,7 +111,7 @@ public:
 	SpriteId							create_sprite(ResourceId id, SceneGraph& sg, int32_t node);
 	void								destroy_sprite(SpriteId id);
 
-	ActorId								create_actor(PhysicsGraph& pg, int32_t node, ActorType::Enum type);
+	ActorId								create_actor(int32_t node, ActorType::Enum type);
 	void								destroy_actor(ActorId id);
 
 	SoundId								play_sound(const char* name, const bool loop = false, const float volume = 1.0f, const Vector3& pos = Vector3::ZERO, const float range = 50.0f);
@@ -133,7 +132,6 @@ private:
 	IdArray<MAX_SOUNDS, Sound> 			m_sounds;
 
 	SceneGraphManager					m_scenegraph_manager;
-	PhysicsGraphManager					m_physicsgraph_manager;
 
 	// Connections
 	List<UnitToSound>					m_unit_to_sound;