Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
SceneObjectOptions.h
Go to the documentation of this file.
1#pragma once
2#include <glm/glm.hpp>
3#include <variant>
4#include <functional>
5
7
8class ICollider;
9
11 glm::vec3 position{0.0f};
12 glm::vec3 scale{1.0f};
13 glm::vec3 rotation{0.0f};
14};
15
18 bool isStatic = false;
19 double mass = 1.0;
20 glm::vec3 velocity = glm::vec3(0.0f);
21
22 PointMassOptions() = default;
23};
24
27 std::function<std::unique_ptr<Physics::Bounding::ICollider>(const ObjectOptions&)> createCollider;
28 bool isStatic = false;
29 double mass = 1.0;
30 glm::vec3 velocity = glm::vec3(0.0f);
31
32 // Helpers for making colliders
33 static RigidBodyOptions Box(ObjectOptions base, bool isStatic = false, double mass = 1.0, glm::vec3 velocity = glm::vec3(0.0f)) {
35 o.base = base;
36 o.mass = mass;
39
40 // Collider will store as local transform
41 o.createCollider = [](auto const& b) -> std::unique_ptr<Physics::Bounding::ICollider>{
42 (void)b;
43 return std::make_unique<Physics::Bounding::BoxCollider>(
44 glm::vec3(0.0f),
45 glm::vec3(0.5f),
46 glm::quat(1.0f, 0.0f, 0.0f, 0.0f)
47 );
48 };
49 return o;
50 }
51};
52
53using CreationOptions = std::variant<ObjectOptions, PointMassOptions, RigidBodyOptions>;
std::variant< ObjectOptions, PointMassOptions, RigidBodyOptions > CreationOptions
PointMassOptions()=default
std::function< std::unique_ptr< Physics::Bounding::ICollider >(const ObjectOptions &)> createCollider
static RigidBodyOptions Box(ObjectOptions base, bool isStatic=false, double mass=1.0, glm::vec3 velocity=glm::vec3(0.0f))