Fixed trajectory renderable
This commit is contained in:
parent
49106683c4
commit
ba732ea64c
|
@ -14,6 +14,7 @@ namespace SHADE
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void SHTrajectoryRenderableComponent::OnCreate(void)
|
void SHTrajectoryRenderableComponent::OnCreate(void)
|
||||||
{
|
{
|
||||||
|
ResetSimulationInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHTrajectoryRenderableComponent::OnDestroy(void)
|
void SHTrajectoryRenderableComponent::OnDestroy(void)
|
||||||
|
@ -22,12 +23,13 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHTrajectoryRenderableComponent::SimulateTrajectory(EntityID eid, SHVec3 force, float timestep, uint32_t maxSteps) noexcept
|
void SHTrajectoryRenderableComponent::SimulateTrajectory(EntityID eid, float mass, SHVec3 force, float timestep, uint32_t maxSteps) noexcept
|
||||||
{
|
{
|
||||||
entityToSimulate = eid;
|
entityToSimulate = eid;
|
||||||
simulationForce = force;
|
simulationForce = force;
|
||||||
simulationTimestep = timestep;
|
simulationTimestep = timestep;
|
||||||
simulationMaxSteps = maxSteps;
|
simulationMaxSteps = maxSteps;
|
||||||
|
objectMass = mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHTrajectoryRenderableComponent::GetSimulationTimestep(void) const noexcept
|
float SHTrajectoryRenderableComponent::GetSimulationTimestep(void) const noexcept
|
||||||
|
@ -35,6 +37,11 @@ namespace SHADE
|
||||||
return simulationTimestep;
|
return simulationTimestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SHTrajectoryRenderableComponent::GetObjectMass(void) const noexcept
|
||||||
|
{
|
||||||
|
return objectMass;
|
||||||
|
}
|
||||||
|
|
||||||
void SHTrajectoryRenderableComponent::ResetSimulationInfo(void) noexcept
|
void SHTrajectoryRenderableComponent::ResetSimulationInfo(void) noexcept
|
||||||
{
|
{
|
||||||
entityToSimulate = MAX_EID;
|
entityToSimulate = MAX_EID;
|
||||||
|
|
|
@ -36,6 +36,9 @@ namespace SHADE
|
||||||
//! plotting a point in the simulation
|
//! plotting a point in the simulation
|
||||||
float simulationTimestep;
|
float simulationTimestep;
|
||||||
|
|
||||||
|
//! mass of the object to simulate
|
||||||
|
float objectMass;
|
||||||
|
|
||||||
//! Entity to simulate trajectory of
|
//! Entity to simulate trajectory of
|
||||||
EntityID entityToSimulate;
|
EntityID entityToSimulate;
|
||||||
|
|
||||||
|
@ -68,12 +71,13 @@ namespace SHADE
|
||||||
SHVec3 GetSimulationForce (void) const noexcept;
|
SHVec3 GetSimulationForce (void) const noexcept;
|
||||||
uint32_t GetSimulationMaxSteps (void) const noexcept;
|
uint32_t GetSimulationMaxSteps (void) const noexcept;
|
||||||
float GetSimulationTimestep (void) const noexcept;
|
float GetSimulationTimestep (void) const noexcept;
|
||||||
|
float GetObjectMass (void) const noexcept;
|
||||||
|
|
||||||
void ResetSimulationInfo (void) noexcept;
|
void ResetSimulationInfo (void) noexcept;
|
||||||
void OnCreate(void) override final;
|
void OnCreate(void) override final;
|
||||||
void OnDestroy(void) override final;
|
void OnDestroy(void) override final;
|
||||||
|
|
||||||
void SimulateTrajectory (EntityID eid, SHVec3 force, float timestep, uint32_t maxSteps) noexcept;
|
void SimulateTrajectory (EntityID eid, float mass, SHVec3 force, float timestep, uint32_t maxSteps) noexcept;
|
||||||
|
|
||||||
RTTR_ENABLE()
|
RTTR_ENABLE()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "SHTrajectoryRenderingSubSystem.h"
|
#include "SHTrajectoryRenderingSubSystem.h"
|
||||||
|
|
||||||
#include "../../../../SHGhostBody.h"
|
|
||||||
#include "ECS_Base/Managers/SHComponentManager.h"
|
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||||
#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h"
|
#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h"
|
||||||
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||||
|
@ -15,6 +14,7 @@
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
||||||
#include "Physics/System/SHPhysicsSystem.h"
|
#include "Physics/System/SHPhysicsSystem.h"
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
#include <Physics/System/SHGhostBody.h>
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,13 @@ namespace SHADE
|
||||||
std::vector<SHVec3> positions{};
|
std::vector<SHVec3> positions{};
|
||||||
std::vector<SHQuaternion> quats{};
|
std::vector<SHQuaternion> quats{};
|
||||||
|
|
||||||
SHGhostBody defaultGhostBody{};
|
auto* rigidBodyComp = SHComponentManager::GetComponent_s<SHRigidBodyComponent>(entityToSimulate);
|
||||||
|
if (!rigidBodyComp)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SHGhostBody defaultGhostBody{*rigidBodyComp};
|
||||||
|
|
||||||
|
defaultGhostBody.mass = comp.GetObjectMass();
|
||||||
|
|
||||||
SHPhysicsSystem::SimulateBodyInfo simulateInfo
|
SHPhysicsSystem::SimulateBodyInfo simulateInfo
|
||||||
{
|
{
|
||||||
|
@ -109,6 +115,8 @@ namespace SHADE
|
||||||
|
|
||||||
comp.ResetSimulationInfo();
|
comp.ResetSimulationInfo();
|
||||||
|
|
||||||
|
std::cout << positions.size() << std::endl;
|
||||||
|
|
||||||
// If has positions, feed data to buffer.
|
// If has positions, feed data to buffer.
|
||||||
if (!positions.empty())
|
if (!positions.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,13 +38,13 @@ namespace SHADE
|
||||||
localInvInertia.y = 1.0f / LOCAL_INERTIA.y;
|
localInvInertia.y = 1.0f / LOCAL_INERTIA.y;
|
||||||
localInvInertia.z = 1.0f / LOCAL_INERTIA.z;
|
localInvInertia.z = 1.0f / LOCAL_INERTIA.z;
|
||||||
|
|
||||||
linearLock.x = rigidBody.GetFreezePositionX() ? 1.0f : 0.0f;
|
linearLock.x = rigidBody.GetFreezePositionX() ? 0.0f : 1.0f;
|
||||||
linearLock.y = rigidBody.GetFreezePositionY() ? 1.0f : 0.0f;
|
linearLock.y = rigidBody.GetFreezePositionY() ? 0.0f : 1.0f;
|
||||||
linearLock.z = rigidBody.GetFreezePositionZ() ? 1.0f : 0.0f;
|
linearLock.z = rigidBody.GetFreezePositionZ() ? 0.0f : 1.0f;
|
||||||
|
|
||||||
angularLock.x = rigidBody.GetFreezeRotationX() ? 1.0f : 0.0f;
|
angularLock.x = rigidBody.GetFreezeRotationX() ? 0.0f : 1.0f;
|
||||||
angularLock.y = rigidBody.GetFreezeRotationY() ? 1.0f : 0.0f;
|
angularLock.y = rigidBody.GetFreezeRotationY() ? 0.0f : 1.0f;
|
||||||
angularLock.z = rigidBody.GetFreezeRotationZ() ? 1.0f : 0.0f;
|
angularLock.z = rigidBody.GetFreezeRotationZ() ? 0.0f : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "SHPhysicsSystem.h"
|
#include "SHPhysicsSystem.h"
|
||||||
|
|
||||||
// Project Headers
|
// Project Headers
|
||||||
#include "../../../SHGhostBody.h"
|
|
||||||
#include "Assets/SHAssetMacros.h"
|
#include "Assets/SHAssetMacros.h"
|
||||||
#include "ECS_Base/Managers/SHComponentManager.h"
|
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||||
#include "ECS_Base/Managers/SHEntityManager.h"
|
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||||
|
@ -25,6 +24,7 @@
|
||||||
#include "Physics/Interface/SHColliderComponent.h"
|
#include "Physics/Interface/SHColliderComponent.h"
|
||||||
#include "Scene/SHSceneManager.h"
|
#include "Scene/SHSceneManager.h"
|
||||||
#include "Scripting/SHScriptEngine.h"
|
#include "Scripting/SHScriptEngine.h"
|
||||||
|
#include "SHGhostBody.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,9 +13,9 @@ namespace SHADE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrajectoryRenderable::SimulateTrajectory(EntityID eid, Vector3 force, float timestep, uint32_t maxSteps)
|
void TrajectoryRenderable::SimulateTrajectory(EntityID eid, float mass, Vector3 force, float timestep, uint32_t maxSteps)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SimulateTrajectory(eid, Convert::ToNative(force), timestep, maxSteps);
|
GetNativeComponent()->SimulateTrajectory(eid, mass, Convert::ToNative(force), timestep, maxSteps);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshAsset TrajectoryRenderable::Mesh::get()
|
MeshAsset TrajectoryRenderable::Mesh::get()
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace SHADE
|
||||||
void set(float val);
|
void set(float val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulateTrajectory(EntityID eid, Vector3 force, float timestep, uint32_t maxSteps);
|
void SimulateTrajectory(EntityID eid, float mass, Vector3 force, float timestep, uint32_t maxSteps);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue