adding plane shape and universal guizmo (this is the wrong branch)
This commit is contained in:
@@ -153,6 +153,11 @@ namespace OpenEngine {
|
||||
{
|
||||
float radius = 1.0f;
|
||||
};
|
||||
|
||||
struct PlaneShapeComponent
|
||||
{
|
||||
float extent = 1.0f;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_HPP
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <core/time.hpp>
|
||||
|
||||
#include <Jolt/Physics/Collision/Shape/Shape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/PlaneShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/EActivation.h>
|
||||
@@ -34,8 +35,13 @@ namespace OpenEngine {
|
||||
auto& c = reg.get<SphereShapeComponent>(e);
|
||||
return CreateRef<SphereShapeSettings>(c.radius);
|
||||
}
|
||||
if (reg.any_of<PlaneShapeComponent>(e)) {
|
||||
auto& c = reg.get<PlaneShapeComponent>(e);
|
||||
const Plane plane({ 0.0f, 1.0f, 0.0f }, 0);
|
||||
return CreateRef<PlaneShapeSettings>(plane, nullptr, c.extent);
|
||||
}
|
||||
|
||||
OE_CORE_ERROR("Entity has no shape component!");
|
||||
OE_CORE_ERROR("Entity {} has no shape component!", reg.get<TagComponent>(e).tag);
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
@@ -352,4 +358,9 @@ namespace OpenEngine {
|
||||
void Scene::OnComponentAdded<IDComponent>(Entity entity, IDComponent& component)
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
void Scene::OnComponentAdded<PlaneShapeComponent>(Entity entity, PlaneShapeComponent& component)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,6 +214,16 @@ namespace OpenEngine {
|
||||
out << YAML::EndMap; //SphereShapeComponent
|
||||
}
|
||||
|
||||
if (entity.HasComponent<PlaneShapeComponent>()) {
|
||||
out << YAML::Key << "PlaneShapeComponent";
|
||||
out << YAML::BeginMap; //PlaneShapeComponent
|
||||
|
||||
auto& psc = entity.GetComponents<PlaneShapeComponent>();
|
||||
out << YAML::Key << "Extent" << YAML::Value << psc.extent;
|
||||
|
||||
out << YAML::EndMap; //PlaneShapeComponent
|
||||
}
|
||||
|
||||
out << YAML::EndMap;
|
||||
}
|
||||
|
||||
@@ -366,6 +376,13 @@ namespace OpenEngine {
|
||||
|
||||
ssc.radius = sphere_shape_component["Radius"].as<float>();
|
||||
}
|
||||
|
||||
auto plane_shape_component = entity["PlaneShapeComponent"];
|
||||
if (sphere_shape_component) {
|
||||
auto& psc = deserializedEntity.AddComponent<PlaneShapeComponent>();
|
||||
|
||||
psc.extent = plane_shape_component["Extent"].as<float>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user