Skip to content

Commit

Permalink
Major refactor and performance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
matt77hias committed Apr 25, 2017
1 parent 9aedf33 commit bf992eb
Show file tree
Hide file tree
Showing 52 changed files with 2,058 additions and 1,114 deletions.
44 changes: 17 additions & 27 deletions MAGE/FPS/src/core/FPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestScript final : public BehaviorScript {

public:

TestScript(SharedPtr< Model > model)
TestScript(SharedPtr< ModelNode > model)
: BehaviorScript(), m_model(model) {}
TestScript(const TestScript &script) = delete;
TestScript(TestScript &&script) = default;
Expand All @@ -19,7 +19,7 @@ class TestScript final : public BehaviorScript {
TestScript &operator=(TestScript &&script) = delete;

virtual void Update(double delta_time) override {
m_model->GetTransform()->AddRotationY((float)delta_time);
m_model->AddRotationY(static_cast< float >(delta_time));

if (g_engine->GetInputManager()->GetKeyboard()->GetKeyPress(DIK_F2)) {
//PostQuitMessage(0);
Expand All @@ -30,7 +30,7 @@ class TestScript final : public BehaviorScript {

private:

SharedPtr< Model > m_model;
SharedPtr< ModelNode > m_model;
};

class TestScene final : public Scene {
Expand All @@ -52,11 +52,9 @@ class TestScene final : public Scene {
//---------------------------------------------------------------------
// Camera
//---------------------------------------------------------------------
SharedPtr< Camera > camera = CreatePerspectiveCamera("camera");
camera->GetTransform()->SetTranslation(0.0f, 2.0f, 0.0f);
SetCamera(camera);
SharedPtr< PerspectiveCameraNode > camera = GetWorld()->CreatePerspectiveCameraNode();
camera->SetTranslationY(2.0f);


//---------------------------------------------------------------------
// ModelDescriptors
//---------------------------------------------------------------------
Expand All @@ -66,25 +64,22 @@ class TestScene final : public Scene {
//---------------------------------------------------------------------
// Models
//---------------------------------------------------------------------
SharedPtr< Model > model_sponza(new Model("sponza", *model_desc_sponza));
model_sponza->GetTransform()->SetScale(10.0f);
GetWorld()->AddModel(model_sponza);
SharedPtr< Model > model_sphere(new Model("sphere", *model_desc_sphere));
model_sphere->GetTransform()->AddTranslationY(0.5f);
GetWorld()->AddModel(model_sphere);
SharedPtr< ModelNode > model_sponza = GetWorld()->CreateModelNode(*model_desc_sponza);
model_sponza->SetScale(10.0f);
SharedPtr< ModelNode > model_sphere = GetWorld()->CreateModelNode(*model_desc_sphere);
model_sphere->AddTranslationY(0.5f);


//---------------------------------------------------------------------
// Lights
//---------------------------------------------------------------------
SharedPtr< OmniLight > omni_light(new OmniLight("omnilight", RGBSpectrum(1.0f, 1.0f, 1.0f)));
omni_light->GetTransform()->SetTranslationY(2.0f);
omni_light->SetDistanceFalloff(0.0f, 2.0f);
GetWorld()->AddLight(omni_light);
SharedPtr< SpotLight > spot_light(new SpotLight("spotlight", RGBSpectrum(1.0f, 1.0f, 1.0f)));
spot_light->GetTransform()->SetTranslation(0.0f, 2.0f, 0.0f);
spot_light->SetDistanceFalloff(0.0f, 3.0f);
GetWorld()->AddLight(spot_light);
SharedPtr< OmniLightNode > omni_light = GetWorld()->CreateOmniLightNode();
omni_light->SetTranslationY(2.0f);
omni_light->GetObject()->SetDistanceFalloff(0.0f, 2.0f);
SharedPtr< SpotLightNode > spot_light = GetWorld()->CreateSpotLightNode();
//spot_light->SetTranslation(0.0f, 2.0f, 0.0f);
spot_light->GetObject()->SetDistanceFalloff(0.0f, 3.0f);
camera->AddChildTransformNode(spot_light);


//---------------------------------------------------------------------
Expand Down Expand Up @@ -117,13 +112,8 @@ class TestScene final : public Scene {
//SharedPtr< BehaviorScript > script(new TestScript(model_teapot));
//AddScript(script);

SharedPtr< BehaviorScript > controller_script(new FPSInputControllerScript(camera->GetTransform()));
SharedPtr< BehaviorScript > controller_script(new FPSInputControllerScript(camera.get()));
AddScript(controller_script);

SharedPtr< BehaviorScript > controller_script2(new FPSInputControllerScript(spot_light->GetTransform()));
AddScript(controller_script2);


SharedPtr< BehaviorScript > stats_script(new StatsScript(text));
AddScript(stats_script);
SharedPtr< BehaviorScript > wireframe_script(new WireframeScript());
Expand Down
15 changes: 0 additions & 15 deletions MAGE/FPS/src/core/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@

#include "core\engine.hpp"

// Cameras
#include "camera\orthographic_camera.hpp"
#include "camera\perspective_camera.hpp"

// Scripts
#include "scripting\behavior_script.hpp"

// Models
#include "model\model.hpp"

// Lights
#include "light\directional_light.hpp"
#include "light\omni_light.hpp"
#include "light\spot_light.hpp"

// Sprites
#include "text\normal_sprite_text.hpp"
#include "text\outline_sprite_text.hpp"
Expand Down
15 changes: 9 additions & 6 deletions MAGE/MAGE.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<ClInclude Include="MAGE\src\binary\binary_reader.hpp" />
<ClInclude Include="MAGE\src\binary\binary_utils.hpp" />
<ClInclude Include="MAGE\src\binary\binary_writer.hpp" />
<ClInclude Include="MAGE\src\buffer\light_buffer.hpp" />
<ClInclude Include="MAGE\src\buffer\material_buffer.hpp" />
<ClInclude Include="MAGE\src\buffer\transform_buffer.hpp" />
<ClInclude Include="MAGE\src\camera\camera.hpp" />
<ClInclude Include="MAGE\src\camera\orthographic_camera.hpp" />
<ClInclude Include="MAGE\src\camera\perspective_camera.hpp" />
Expand All @@ -45,9 +48,9 @@
<ClInclude Include="MAGE\src\input\input_manager.hpp" />
<ClInclude Include="MAGE\src\input\keyboard.hpp" />
<ClInclude Include="MAGE\src\input\mouse.hpp" />
<ClInclude Include="MAGE\src\light\ambient_light.hpp" />
<ClInclude Include="MAGE\src\light\directional_light.hpp" />
<ClInclude Include="MAGE\src\light\light.hpp" />
<ClInclude Include="MAGE\src\light\light_buffer.hpp" />
<ClInclude Include="MAGE\src\light\omni_light.hpp" />
<ClInclude Include="MAGE\src\light\spot_light.hpp" />
<ClInclude Include="MAGE\src\logging\error.hpp" />
Expand All @@ -66,6 +69,7 @@
<ClInclude Include="MAGE\src\math\math_utils.hpp" />
<ClInclude Include="MAGE\src\math\sprite_transform.hpp" />
<ClInclude Include="MAGE\src\math\transform.hpp" />
<ClInclude Include="MAGE\src\math\transform_node.hpp" />
<ClInclude Include="MAGE\src\math\view_frustum.hpp" />
<ClInclude Include="MAGE\src\memory\allocation.hpp" />
<ClInclude Include="MAGE\src\memory\memory.hpp" />
Expand Down Expand Up @@ -108,6 +112,7 @@
<ClInclude Include="MAGE\src\resource\resource_factory.hpp" />
<ClInclude Include="MAGE\src\resource\resource_pool.hpp" />
<ClInclude Include="MAGE\src\scene\scene.hpp" />
<ClInclude Include="MAGE\src\scene\scene_node.hpp" />
<ClInclude Include="MAGE\src\scripting\behavior_script.hpp" />
<ClInclude Include="MAGE\src\scripting\variable.hpp" />
<ClInclude Include="MAGE\src\scripting\variable_script.hpp" />
Expand Down Expand Up @@ -165,12 +170,11 @@
<ClInclude Include="MAGE\src\ui\combo_box.hpp" />
<ClInclude Include="MAGE\src\ui\main_window.hpp" />
<ClInclude Include="MAGE\src\ui\main_window_settings.hpp" />
<ClInclude Include="MAGE\src\world\transform_buffer.hpp" />
<ClInclude Include="MAGE\src\world\world.hpp" />
<ClInclude Include="MAGE\src\world\world_object.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="MAGE\src\binary\binary_writer.cpp" />
<ClCompile Include="MAGE\src\buffer\transform_buffer.cpp" />
<ClCompile Include="MAGE\src\camera\orthographic_camera.cpp" />
<ClCompile Include="MAGE\src\camera\perspective_camera.cpp" />
<ClCompile Include="MAGE\src\core\engine.cpp" />
Expand All @@ -191,6 +195,7 @@
<ClCompile Include="MAGE\src\material\spectrum.cpp" />
<ClCompile Include="MAGE\src\math\bounding_volume.cpp" />
<ClCompile Include="MAGE\src\math\sprite_transform.cpp" />
<ClCompile Include="MAGE\src\math\transform_node.cpp" />
<ClCompile Include="MAGE\src\math\view_frustum.cpp" />
<ClCompile Include="MAGE\src\memory\memory_arena.cpp" />
<ClCompile Include="MAGE\src\mesh\sprite_batch_mesh.cpp" />
Expand Down Expand Up @@ -248,9 +253,7 @@
<ClCompile Include="MAGE\src\timer\timer.cpp" />
<ClCompile Include="MAGE\src\ui\combo_box.cpp" />
<ClCompile Include="MAGE\src\ui\main_window.cpp" />
<ClCompile Include="MAGE\src\world\transform_buffer.cpp" />
<ClCompile Include="MAGE\src\world\world.cpp" />
<ClCompile Include="MAGE\src\world\world_object.cpp" />
</ItemGroup>
<ItemGroup>
<FxCompile Include="MAGE\shaders\lambertian.fx">
Expand Down Expand Up @@ -397,6 +400,7 @@
<ItemGroup>
<None Include="MAGE\src\binary\binary_reader.tpp" />
<None Include="MAGE\src\binary\binary_writer.tpp" />
<None Include="MAGE\src\math\transform_node.tpp" />
<None Include="MAGE\src\memory\memory_arena.tpp" />
<None Include="MAGE\src\mesh\msh\msh_loader.tpp" />
<None Include="MAGE\src\mesh\msh\msh_reader.tpp" />
Expand All @@ -406,7 +410,6 @@
<None Include="MAGE\src\model\mdl\mdl_loader.tpp" />
<None Include="MAGE\src\model\mdl\mdl_reader.tpp" />
<None Include="MAGE\src\model\mdl\mdl_writer.tpp" />
<None Include="MAGE\src\model\model.tpp" />
<None Include="MAGE\src\model\model_descriptor.tpp" />
<None Include="MAGE\src\model\model_loader.tpp" />
<None Include="MAGE\src\rendering\constant_buffer.tpp" />
Expand Down
53 changes: 34 additions & 19 deletions MAGE/MAGE.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@
<Filter Include="Header Files\model\mdl">
<UniqueIdentifier>{30b20d94-ffc8-40c1-b7d1-60836c97c92c}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\buffer">
<UniqueIdentifier>{6611e24b-5030-4508-99c0-733263f8d080}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\buffer">
<UniqueIdentifier>{d58afbdd-86c4-4381-a6d1-4e4284f2e246}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MAGE\src\collection\collection.hpp">
Expand Down Expand Up @@ -459,15 +465,9 @@
<ClInclude Include="MAGE\src\model\model_descriptor.hpp">
<Filter>Header Files\model</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\world\transform_buffer.hpp">
<Filter>Header Files\world</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\world\world.hpp">
<Filter>Header Files\world</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\world\world_object.hpp">
<Filter>Header Files\world</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\binary\binary_reader.hpp">
<Filter>Header Files\binary</Filter>
</ClInclude>
Expand Down Expand Up @@ -648,9 +648,6 @@
<ClInclude Include="MAGE\src\light\spot_light.hpp">
<Filter>Header Files\light</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\light\directional_light.hpp">
<Filter>Header Files\light</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\light\light.hpp">
<Filter>Header Files\light</Filter>
</ClInclude>
Expand All @@ -666,9 +663,27 @@
<ClInclude Include="MAGE\src\rendering\structured_buffer.hpp">
<Filter>Header Files\rendering</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\light\light_buffer.hpp">
<ClInclude Include="MAGE\src\math\transform_node.hpp">
<Filter>Header Files\math</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\buffer\material_buffer.hpp">
<Filter>Header Files\buffer</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\buffer\light_buffer.hpp">
<Filter>Header Files\buffer</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\buffer\transform_buffer.hpp">
<Filter>Header Files\buffer</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\light\ambient_light.hpp">
<Filter>Header Files\light</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\light\directional_light.hpp">
<Filter>Header Files\light</Filter>
</ClInclude>
<ClInclude Include="MAGE\src\scene\scene_node.hpp">
<Filter>Header Files\scene</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MAGE\src\core\engine.cpp">
Expand Down Expand Up @@ -779,9 +794,6 @@
<ClCompile Include="MAGE\src\world\world.cpp">
<Filter>Source Files\world</Filter>
</ClCompile>
<ClCompile Include="MAGE\src\world\transform_buffer.cpp">
<Filter>Source Files\world</Filter>
</ClCompile>
<ClCompile Include="MAGE\src\math\view_frustum.cpp">
<Filter>Source Files\math</Filter>
</ClCompile>
Expand Down Expand Up @@ -845,9 +857,6 @@
<ClCompile Include="MAGE\src\font\sprite_font.cpp">
<Filter>Source Files\font</Filter>
</ClCompile>
<ClCompile Include="MAGE\src\world\world_object.cpp">
<Filter>Source Files\world</Filter>
</ClCompile>
<ClCompile Include="MAGE\src\camera\perspective_camera.cpp">
<Filter>Source Files\camera</Filter>
</ClCompile>
Expand Down Expand Up @@ -914,6 +923,12 @@
<ClCompile Include="MAGE\src\sprite\sprite_object.cpp">
<Filter>Source Files\sprite</Filter>
</ClCompile>
<ClCompile Include="MAGE\src\math\transform_node.cpp">
<Filter>Source Files\math</Filter>
</ClCompile>
<ClCompile Include="MAGE\src\buffer\transform_buffer.cpp">
<Filter>Source Files\buffer</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="MAGE\shaders\lambertian.fx">
Expand Down Expand Up @@ -972,9 +987,6 @@
<None Include="MAGE\src\scene\scene.tpp">
<Filter>Header Files\scene</Filter>
</None>
<None Include="MAGE\src\model\model.tpp">
<Filter>Header Files\model</Filter>
</None>
<None Include="MAGE\src\text\sprite_text.tpp">
<Filter>Header Files\text</Filter>
</None>
Expand Down Expand Up @@ -1005,5 +1017,8 @@
<None Include="MAGE\src\rendering\structured_buffer.tpp">
<Filter>Header Files\rendering</Filter>
</None>
<None Include="MAGE\src\math\transform_node.tpp">
<Filter>Header Files\math</Filter>
</None>
</ItemGroup>
</Project>
Loading

0 comments on commit bf992eb

Please sign in to comment.