diff --git a/Assets/Scenes/M2Scene.shade b/Assets/Scenes/M2Scene.shade index ff5e5fd6..76ed77af 100644 --- a/Assets/Scenes/M2Scene.shade +++ b/Assets/Scenes/M2Scene.shade @@ -82,7 +82,7 @@ Transform Component: Translate: {x: 0, y: 4.28833103, z: 0} Rotate: {x: -0, y: 0, z: -0} - Scale: {x: 1, y: 1, z: 1} + Scale: {x: 1, y: 0, z: 1} IsActive: true RigidBody Component: Type: Dynamic @@ -108,14 +108,6 @@ Density: 1 Position Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} - - Is Trigger: false - Type: Box - Half Extents: {x: 2, y: 2, z: 2} - Friction: 0.400000006 - Bounciness: 0 - Density: 1 - Position Offset: {x: 0, y: 0, z: 0} - Rotation Offset: {x: 0, y: 0, z: 0} IsActive: true Scripts: ~ - EID: 65537 diff --git a/SHADE_Engine/src/Math/SHMathHelpers.hpp b/SHADE_Engine/src/Math/SHMathHelpers.hpp index cdbe1643..554fa317 100644 --- a/SHADE_Engine/src/Math/SHMathHelpers.hpp +++ b/SHADE_Engine/src/Math/SHMathHelpers.hpp @@ -53,7 +53,7 @@ namespace SHADE for (auto value : values) { - max = Min(max, value); + max = Max(max, value); } return max; diff --git a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp index 38d44984..03de360d 100644 --- a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp +++ b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp @@ -18,6 +18,7 @@ #include "ECS_Base/Managers/SHComponentManager.h" #include "ECS_Base/Managers/SHEntityManager.h" #include "ECS_Base/Managers/SHSystemManager.h" +#include "Editor/SHEditor.h" #include "Math/SHMathHelpers.h" namespace SHADE @@ -35,7 +36,7 @@ namespace SHADE {} SHTransformSystem::TransformPostPhysicsUpdate::TransformPostPhysicsUpdate() - : SHSystemRoutine { "Transform Post-Physics Update", false } + : SHSystemRoutine { "Transform Post-Physics Update", true } {} @@ -54,7 +55,28 @@ namespace SHADE { // Get the current scene graph to traverse and update const auto& SCENE_GRAPH = SHSceneManager::GetCurrentSceneGraph(); + +#ifdef SHEDITOR + + // When editor is not in play, only clear all dirty flags. No update required. + + const auto* EDITOR = SHSystemManager::GetSystem(); + if (EDITOR && EDITOR->editorState != SHEditor::State::PLAY) + { + auto& transformsSet = SHComponentManager::GetDense(); + for (auto& tfComp : transformsSet) + tfComp.dirty = false; + } + else + { + UpdateEntity(SCENE_GRAPH.GetRoot(), true); + } + +#else + UpdateEntity(SCENE_GRAPH.GetRoot(), true); + +#endif } void SHTransformSystem::Init() diff --git a/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp b/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp index 135e7e42..d7db2c64 100644 --- a/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHColliderComponent.cpp @@ -107,6 +107,7 @@ namespace SHADE const SHVec3& RELATIVE_EXTENTS = box->GetRelativeExtents(); // Recompute world extents based on new scale and fixed relative extents + const SHVec3 WORLD_EXTENTS = RELATIVE_EXTENTS * (scale * 0.5f); box->SetWorldExtents(WORLD_EXTENTS); @@ -118,6 +119,7 @@ namespace SHADE const float RELATIVE_RADIUS = sphere->GetRelativeRadius(); // Recompute world radius based on new scale and fixed radius + const float MAX_SCALE = SHMath::Max({ scale.x, scale.y, scale.z }); const float WORLD_RADIUS = RELATIVE_RADIUS * MAX_SCALE * 0.5f; sphere->SetWorldRadius(WORLD_RADIUS); diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp index 43906c22..f597077f 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp @@ -206,7 +206,7 @@ namespace SHADE } // Set the half extents relative to world scale - const SHVec3 WORLD_EXTENTS = correctedHalfExtents * COLLIDER->GetScale(); + const SHVec3 WORLD_EXTENTS = correctedHalfExtents * COLLIDER->GetScale() * 0.5f; if (type != Type::BOX) { diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp index 6ab17077..a5ca957a 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp @@ -308,12 +308,9 @@ namespace SHADE { colliderComponent->position = WORLD_POS; colliderComponent->orientation = WORLD_ROT; + colliderComponent->scale = WORLD_SCL; - if (colliderComponent->scale != WORLD_SCL) - { - colliderComponent->scale = WORLD_SCL; - colliderComponent->RecomputeCollisionShapes(); - } + colliderComponent->RecomputeCollisionShapes(); } }