WIP Collision meshes
This commit is contained in:
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef Components_MeshShape_h__
|
||||||
|
#define Components_MeshShape_h__
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
struct MeshShape : Component
|
||||||
|
{
|
||||||
|
std::string Filename;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Components_MeshShape_h__
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef Components_StaticMeshShape_h__
|
||||||
|
#define Components_StaticMeshShape_h__
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
struct StaticMeshShape : Component
|
||||||
|
{
|
||||||
|
std::string Filename;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Components_StaticMeshShape_h__
|
||||||
@@ -58,8 +58,10 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity, "Physics");
|
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity, "Physics");
|
||||||
auto sphereShapeComponent = m_World->GetComponent<Components::SphereShape>(entity, "SphereShape");
|
auto sphereShapeComponent = m_World->GetComponent<Components::SphereShape>(entity, "SphereShape");
|
||||||
auto boxShapeComponent = m_World->GetComponent<Components::BoxShape>(entity, "BoxShape");
|
auto boxShapeComponent = m_World->GetComponent<Components::BoxShape>(entity, "BoxShape");
|
||||||
|
auto meshShapeComponent = m_World->GetComponent<Components::MeshShape>(entity, "MeshShape");
|
||||||
|
auto staticMeshShapeComponent = m_World->GetComponent<Components::StaticMeshShape>(entity, "StaticMeshShape");
|
||||||
|
|
||||||
if (physicsComponent || sphereShapeComponent || boxShapeComponent)
|
if (physicsComponent || sphereShapeComponent || boxShapeComponent || meshShapeComponent || staticMeshShapeComponent)
|
||||||
{
|
{
|
||||||
if (m_PhysicsData.find(entity) == m_PhysicsData.end()) {
|
if (m_PhysicsData.find(entity) == m_PhysicsData.end()) {
|
||||||
SetUpPhysicsState(entity, parent);
|
SetUpPhysicsState(entity, parent);
|
||||||
@@ -177,8 +179,10 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
|
|||||||
auto compoundShapeComponent = m_World->GetComponent<Components::CompoundShape>(entity, "CompoundShape");
|
auto compoundShapeComponent = m_World->GetComponent<Components::CompoundShape>(entity, "CompoundShape");
|
||||||
auto sphereShapeComponent = m_World->GetComponent<Components::SphereShape>(entity, "SphereShape");
|
auto sphereShapeComponent = m_World->GetComponent<Components::SphereShape>(entity, "SphereShape");
|
||||||
auto boxShapeComponent = m_World->GetComponent<Components::BoxShape>(entity, "BoxShape");
|
auto boxShapeComponent = m_World->GetComponent<Components::BoxShape>(entity, "BoxShape");
|
||||||
|
auto meshShapeComponent = m_World->GetComponent<Components::MeshShape>(entity, "MeshShape");
|
||||||
|
auto staticMeshShapeComponent = m_World->GetComponent<Components::StaticMeshShape>(entity, "StaticMeshShape");
|
||||||
|
|
||||||
if (compoundShapeComponent && (sphereShapeComponent || boxShapeComponent)) {
|
if (compoundShapeComponent && (sphereShapeComponent || boxShapeComponent || meshShapeComponent || staticMeshShapeComponent)) {
|
||||||
LOG_WARNING("Entity %i has both compound shape and normal shape! Normal shapes must be children to entity with compound shape.", entity);
|
LOG_WARNING("Entity %i has both compound shape and normal shape! Normal shapes must be children to entity with compound shape.", entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,8 +216,11 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
|
|||||||
physicsData->CollisionShape = new btBoxShape(btVector3(boxShapeComponent->Width, boxShapeComponent->Height, boxShapeComponent->Depth));
|
physicsData->CollisionShape = new btBoxShape(btVector3(boxShapeComponent->Width, boxShapeComponent->Height, boxShapeComponent->Depth));
|
||||||
} else if (sphereShapeComponent) {
|
} else if (sphereShapeComponent) {
|
||||||
physicsData->CollisionShape = new btSphereShape(sphereShapeComponent->Radius);
|
physicsData->CollisionShape = new btSphereShape(sphereShapeComponent->Radius);
|
||||||
|
} else if (meshShapeComponent) {
|
||||||
|
// TODO: Collision mesh things go here
|
||||||
|
//new btConvexTriangleMeshShape()
|
||||||
}
|
}
|
||||||
if (boxShapeComponent || sphereShapeComponent) {
|
if (boxShapeComponent || sphereShapeComponent || meshShapeComponent || staticMeshShapeComponent) {
|
||||||
btTransform transform;
|
btTransform transform;
|
||||||
transform.setFromOpenGLMatrix(glm::value_ptr(glm::translate(glm::mat4(), transformComponent->Position) * glm::toMat4(transformComponent->Orientation)));
|
transform.setFromOpenGLMatrix(glm::value_ptr(glm::translate(glm::mat4(), transformComponent->Position) * glm::toMat4(transformComponent->Orientation)));
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "Components/CompoundShape.h"
|
#include "Components/CompoundShape.h"
|
||||||
#include "Components/BoxShape.h"
|
#include "Components/BoxShape.h"
|
||||||
#include "Components/SphereShape.h"
|
#include "Components/SphereShape.h"
|
||||||
|
#include "Components/MeshShape.h"
|
||||||
|
#include "Components/StaticMeshShape.h"
|
||||||
#include "Components/BallSocketConstraint.h"
|
#include "Components/BallSocketConstraint.h"
|
||||||
#include "Components/HingeConstraint.h"
|
#include "Components/HingeConstraint.h"
|
||||||
#include "Components/SliderConstraint.h"
|
#include "Components/SliderConstraint.h"
|
||||||
|
|||||||
@@ -118,6 +118,7 @@
|
|||||||
<ClInclude Include="..\..\src\Components\FreeSteering.h" />
|
<ClInclude Include="..\..\src\Components\FreeSteering.h" />
|
||||||
<ClInclude Include="..\..\src\Components\HingeConstraint.h" />
|
<ClInclude Include="..\..\src\Components\HingeConstraint.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Input.h" />
|
<ClInclude Include="..\..\src\Components\Input.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\MeshShape.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Model.h" />
|
<ClInclude Include="..\..\src\Components\Model.h" />
|
||||||
<ClInclude Include="..\..\src\Components\ParticleEmitter.h" />
|
<ClInclude Include="..\..\src\Components\ParticleEmitter.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Physics.h" />
|
<ClInclude Include="..\..\src\Components\Physics.h" />
|
||||||
@@ -128,6 +129,7 @@
|
|||||||
<ClInclude Include="..\..\src\Components\SphereShape.h" />
|
<ClInclude Include="..\..\src\Components\SphereShape.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Sprite.h" />
|
<ClInclude Include="..\..\src\Components\Sprite.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Stat.h" />
|
<ClInclude Include="..\..\src\Components\Stat.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\StaticMeshShape.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Template.h" />
|
<ClInclude Include="..\..\src\Components\Template.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Transform.h" />
|
<ClInclude Include="..\..\src\Components\Transform.h" />
|
||||||
<ClInclude Include="..\..\src\CubemapTexture.h" />
|
<ClInclude Include="..\..\src\CubemapTexture.h" />
|
||||||
|
|||||||
@@ -154,6 +154,12 @@
|
|||||||
<ClInclude Include="..\..\src\Components\BallSocketConstraint.h">
|
<ClInclude Include="..\..\src\Components\BallSocketConstraint.h">
|
||||||
<Filter>Components</Filter>
|
<Filter>Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\MeshShape.h">
|
||||||
|
<Filter>Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\StaticMeshShape.h">
|
||||||
|
<Filter>Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\Shaders\AABB.frag.glsl">
|
<None Include="..\..\src\Shaders\AABB.frag.glsl">
|
||||||
|
|||||||
Reference in New Issue
Block a user