Improved particles and trajectory rendering #430
|
@ -14,6 +14,7 @@ namespace SHADE
|
|||
/***************************************************************************/
|
||||
void SHTrajectoryRenderableComponent::OnCreate(void)
|
||||
{
|
||||
ResetSimulationInfo();
|
||||
}
|
||||
|
||||
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;
|
||||
simulationForce = force;
|
||||
simulationTimestep = timestep;
|
||||
simulationMaxSteps = maxSteps;
|
||||
objectMass = mass;
|
||||
}
|
||||
|
||||
float SHTrajectoryRenderableComponent::GetSimulationTimestep(void) const noexcept
|
||||
|
@ -35,6 +37,11 @@ namespace SHADE
|
|||
return simulationTimestep;
|
||||
}
|
||||
|
||||
float SHTrajectoryRenderableComponent::GetObjectMass(void) const noexcept
|
||||
{
|
||||
return objectMass;
|
||||
}
|
||||
|
||||
void SHTrajectoryRenderableComponent::ResetSimulationInfo(void) noexcept
|
||||
{
|
||||
entityToSimulate = MAX_EID;
|
||||
|
|
|
@ -36,6 +36,9 @@ namespace SHADE
|
|||
//! plotting a point in the simulation
|
||||
float simulationTimestep;
|
||||
|
||||
//! mass of the object to simulate
|
||||
float objectMass;
|
||||
|
||||
//! Entity to simulate trajectory of
|
||||
EntityID entityToSimulate;
|
||||
|
||||
|
@ -68,12 +71,13 @@ namespace SHADE
|
|||
SHVec3 GetSimulationForce (void) const noexcept;
|
||||
uint32_t GetSimulationMaxSteps (void) const noexcept;
|
||||
float GetSimulationTimestep (void) const noexcept;
|
||||
float GetObjectMass (void) const noexcept;
|
||||
|
||||
void ResetSimulationInfo (void) noexcept;
|
||||
void OnCreate(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()
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHTrajectoryRenderingSubSystem.h"
|
||||
|
||||
#include "../../../../SHGhostBody.h"
|
||||
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||
#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h"
|
||||
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||
|
@ -15,6 +14,7 @@
|
|||
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
||||
#include "Physics/System/SHPhysicsSystem.h"
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include <Physics/System/SHGhostBody.h>
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -88,7 +88,13 @@ namespace SHADE
|
|||
std::vector<SHVec3> positions{};
|
||||
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
|
||||
{
|
||||
|
@ -109,6 +115,8 @@ namespace SHADE
|
|||
|
||||
comp.ResetSimulationInfo();
|
||||
|
||||
std::cout << positions.size() << std::endl;
|
||||
|
||||
// If has positions, feed data to buffer.
|
||||
if (!positions.empty())
|
||||
{
|
||||
|
|
|
@ -38,13 +38,13 @@ namespace SHADE
|
|||
localInvInertia.y = 1.0f / LOCAL_INERTIA.y;
|
||||
localInvInertia.z = 1.0f / LOCAL_INERTIA.z;
|
||||
|
||||
linearLock.x = rigidBody.GetFreezePositionX() ? 1.0f : 0.0f;
|
||||
linearLock.y = rigidBody.GetFreezePositionY() ? 1.0f : 0.0f;
|
||||
linearLock.z = rigidBody.GetFreezePositionZ() ? 1.0f : 0.0f;
|
||||
linearLock.x = rigidBody.GetFreezePositionX() ? 0.0f : 1.0f;
|
||||
linearLock.y = rigidBody.GetFreezePositionY() ? 0.0f : 1.0f;
|
||||
linearLock.z = rigidBody.GetFreezePositionZ() ? 0.0f : 1.0f;
|
||||
|
||||
angularLock.x = rigidBody.GetFreezeRotationX() ? 1.0f : 0.0f;
|
||||
angularLock.y = rigidBody.GetFreezeRotationY() ? 1.0f : 0.0f;
|
||||
angularLock.z = rigidBody.GetFreezeRotationZ() ? 1.0f : 0.0f;
|
||||
angularLock.x = rigidBody.GetFreezeRotationX() ? 0.0f : 1.0f;
|
||||
angularLock.y = rigidBody.GetFreezeRotationY() ? 0.0f : 1.0f;
|
||||
angularLock.z = rigidBody.GetFreezeRotationZ() ? 0.0f : 1.0f;
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,6 @@
|
|||
#include "SHPhysicsSystem.h"
|
||||
|
||||
// Project Headers
|
||||
#include "../../../SHGhostBody.h"
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||
|
@ -25,6 +24,7 @@
|
|||
#include "Physics/Interface/SHColliderComponent.h"
|
||||
#include "Scene/SHSceneManager.h"
|
||||
#include "Scripting/SHScriptEngine.h"
|
||||
#include "SHGhostBody.h"
|
||||
|
||||
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()
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace SHADE
|
|||
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