Tramway SDK
physics.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_PHYSICS_PHYSICS_H
4#define TRAM_SDK_PHYSICS_PHYSICS_H
5
6#include <framework/core.h>
7#include <framework/math.h>
8
9#include <vector>
10
11struct btCollisionShape;
12struct btCollisionObject;
13struct btRigidBody;
14
15namespace tram {
16 class PhysicsComponent;
17}
18
19namespace tram::Physics {
20
21void Init();
22void Update();
23
24enum CollisionGroup : uint32_t {
25 COLL_WORLDOBJ = 2, //< Worldspawns
26 COLL_STATICOBJ = 4, //< Decorations, doors, elevators and platforms
27 COLL_DYNAMICOBJ = 8, //< Crates and other
28 COLL_TRIGGER = 16, //< Triggers
29 COLL_PLAYER = 32, //< Players
30 COLL_MONSTER = 64, //< Monsters and other NPCs
31 COLL_VEHICLE = 128 //< Trams and microbuses
32};
33
34struct Collision {
38 float distance;
39};
40
41namespace API { struct RigidbodyMetadata; }
42
44 btCollisionShape* bt_shape;
45};
46
47struct trigger_t {
48 btCollisionObject* bt_collisionshape;
50};
51
53 btRigidBody* bt_rigidbody;
55};
56
57class CollisionShape;
58
59Collision Raycast(const vec3& from, const vec3& to, uint32_t collision_mask = -1);
60std::vector<Collision> Shapecast(const CollisionShape& shape, const vec3& from, const vec3& to, uint32_t collision_mask = -1);
61
62}
63
64#endif // TRAM_SDK_PHYSICS_PHYSICS_H
Rigidbody wrapper.
Definition: physics.h:12
void Init()
Initializes the physics system.
Definition: physics.cpp:37
std::vector< Collision > Shapecast(const CollisionShape &shape, const vec3 &from, const vec3 &to, uint32_t collision_mask)
I have no idea if this function works. (yes it does)
Definition: physics.cpp:67
CollisionGroup
Definition: physics.h:24
@ COLL_TRIGGER
Definition: physics.h:28
@ COLL_VEHICLE
Definition: physics.h:31
@ COLL_WORLDOBJ
Definition: physics.h:25
@ COLL_STATICOBJ
Definition: physics.h:26
@ COLL_PLAYER
Definition: physics.h:29
@ COLL_MONSTER
Definition: physics.h:30
@ COLL_DYNAMICOBJ
Definition: physics.h:27
Collision Raycast(const vec3 &from, const vec3 &to, uint32_t collision_mask)
Performs a raycast.
Definition: physics.cpp:60
void Update()
Updates the physics system.
Definition: physics.cpp:48
Serialization, i.e.
glm::vec3 vec3
Definition: math.h:11
Definition: bullet.cpp:100
Physics collision data.
Definition: physics.h:34
vec3 normal
Normal vector of the surface that the collision happened with.
Definition: physics.h:37
vec3 point
Position of the collision in world space.
Definition: physics.h:36
PhysicsComponent * collider
Pointer to a PhysicsComponent that owns the rigidbody with which the collision happened.
Definition: physics.h:35
float distance
Distance of the collision, i.e.
Definition: physics.h:38
Shape for a collider.
Definition: collisionshape.h:32
Definition: physics.h:43
btCollisionShape * bt_shape
Definition: physics.h:44
Definition: physics.h:52
btRigidBody * bt_rigidbody
Definition: physics.h:53
API::RigidbodyMetadata * bt_metadata
Definition: physics.h:54
Definition: physics.h:47
API::RigidbodyMetadata * bt_metadata
Definition: physics.h:49
btCollisionObject * bt_collisionshape
Definition: physics.h:48