physics
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "tier1/utlvector.h"
|
||||
#include "rendering.h"
|
||||
#include "baseentity.h"
|
||||
#include "physics.h"
|
||||
|
||||
class CBrushEntity: public CBaseEntity
|
||||
{
|
||||
@@ -14,6 +15,8 @@ public:
|
||||
virtual void Think( float fDelta ) override;
|
||||
|
||||
CUtlVector<Triangle_t> m_mesh;
|
||||
Collider *m_collider;
|
||||
RigidBodyHandle *m_body;
|
||||
};
|
||||
|
||||
class C_BrushEntity: public C_BaseEntity
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef PHYSICS_H
|
||||
#define PHYSICS_H
|
||||
|
||||
#include "tier0/lib.h"
|
||||
#include "stdint.h"
|
||||
|
||||
|
||||
typedef void Collider;
|
||||
typedef void RigidBodyHandle;
|
||||
|
||||
template <typename T>
|
||||
struct Point {
|
||||
T x, y, z;
|
||||
};
|
||||
|
||||
typedef struct u128 {
|
||||
uint64_t a;
|
||||
uint64_t b;
|
||||
} u128;
|
||||
|
||||
#include "physics_gen.h"
|
||||
|
||||
extern funnyphysics *px;
|
||||
|
||||
#endif
|
||||
|
||||
96
public/physics_gen.h
Normal file
96
public/physics_gen.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#ifndef RAPIER_H
|
||||
#define RAPIER_H
|
||||
|
||||
|
||||
|
||||
typedef struct funnyphysics funnyphysics;
|
||||
|
||||
typedef struct px_collider_params {
|
||||
float friction;
|
||||
} px_collider_params;
|
||||
|
||||
typedef struct px_vec3 {
|
||||
float m[3];
|
||||
} px_vec3;
|
||||
|
||||
typedef struct px_cast_result {
|
||||
int8_t hit;
|
||||
float time;
|
||||
struct px_vec3 witness1;
|
||||
struct px_vec3 witness2;
|
||||
struct px_vec3 normal1;
|
||||
struct px_vec3 normal2;
|
||||
} px_cast_result;
|
||||
|
||||
typedef struct px_matrix {
|
||||
float m[16];
|
||||
} px_matrix;
|
||||
|
||||
typedef struct px_rigidbody_params {
|
||||
float velocity[3];
|
||||
float angular_velocity[3];
|
||||
float gravity_scale;
|
||||
float linear_damping;
|
||||
float angular_damping;
|
||||
uint8_t continous;
|
||||
uint8_t sleeping;
|
||||
uint8_t lockrotx;
|
||||
uint8_t lockroty;
|
||||
uint8_t lockrotz;
|
||||
uint8_t lockposx;
|
||||
uint8_t lockposy;
|
||||
uint8_t lockposz;
|
||||
int8_t dominance;
|
||||
} px_rigidbody_params;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
Collider *px_ball(float radius, struct px_collider_params params);
|
||||
|
||||
Collider *px_box(float x, float y, float z, struct px_collider_params params);
|
||||
|
||||
struct px_cast_result px_box_cast(struct funnyphysics *px_world,
|
||||
float x,
|
||||
float y,
|
||||
float z,
|
||||
struct px_vec3 pos,
|
||||
struct px_vec3 rot,
|
||||
struct px_vec3 vel,
|
||||
float time);
|
||||
|
||||
void px_frame(struct funnyphysics *px_world, float delta);
|
||||
|
||||
struct px_matrix px_getmatrix(struct funnyphysics *px_world, RigidBodyHandle *body);
|
||||
|
||||
struct px_vec3 px_getposition(struct funnyphysics *px_world, RigidBodyHandle *body);
|
||||
|
||||
struct px_vec3 px_getvelocity(struct funnyphysics *px_world, RigidBodyHandle *body);
|
||||
|
||||
struct funnyphysics *px_init(void);
|
||||
|
||||
RigidBodyHandle *px_rigidbody(struct funnyphysics *px_world,
|
||||
Collider *collider,
|
||||
struct px_matrix m,
|
||||
struct px_rigidbody_params params);
|
||||
|
||||
void px_setposition(struct funnyphysics *px_world, RigidBodyHandle *body, struct px_vec3 vec);
|
||||
|
||||
void px_setvelocity(struct funnyphysics *px_world, RigidBodyHandle *body, struct px_vec3 vec);
|
||||
|
||||
RigidBodyHandle *px_staticbody(struct funnyphysics *px_world,
|
||||
Collider *collider,
|
||||
struct px_matrix m);
|
||||
|
||||
Collider *px_trimesh(const Point<float> *ptr_vert,
|
||||
size_t len_vert,
|
||||
const uint32_t (*ptr_ind)[3],
|
||||
size_t len_ind,
|
||||
struct px_collider_params params);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* RAPIER_H */
|
||||
Reference in New Issue
Block a user