Stardew Engine
Loading...
Searching...
No Matches
Physics2D.h
Go to the documentation of this file.
1#ifndef PHYSICS2D_H
2#define PHYSICS2D_H
3#include "HandleDefs.h"
4#include <cglm/cglm.h>
5#include "DynArray.h"
6
7// TODO: Document this file
8
9typedef vec2 Physics2DPoint;
10struct Transform2D;
11
13{
14 float w, h;
15};
16
18{
20};
21
23{
24 vec2 center;
25 float radius;
26};
27
36
47
52
53void Ph_Init();
54
55HPhysicsWorld Ph_GetPhysicsWorld(float gravityX, float gravityY, float pixelsPerMeter);
56
57void Ph_PhysicsWorldStep(HPhysicsWorld hWorld, float timestep, int substepCount);
58
60
62
63void Ph_PixelCoords2PhysicsCoords(HPhysicsWorld world, vec2 inPixelCoords, vec2 outPhysicsCoords);
64
65void Ph_PhysicsCoords2PixelCoords(HPhysicsWorld world, vec2 inPhysicsCoords, vec2 outPixelCoords);
66
67H2DBody Ph_GetStaticBody2D(HPhysicsWorld world, struct PhysicsShape2D* pShape, struct Transform2D* pTransform, HEntity2D entity, bool bIsSensor, int entityComponentIndex, bool bGenerateSensorEvents);
68
69H2DBody Ph_GetDynamicBody(HPhysicsWorld world, struct PhysicsShape2D* pShape, struct KinematicBodyOptions* pOptions, struct Transform2D* pTransform, HEntity2D entity, bool bIsSensor, int entityComponentIndex, bool bGenerateSensorEvents);
70
72
73void Ph_SetDynamicBodyVelocity(H2DBody hBody, vec2 velocity);
74
75void Ph_GetDynamicBodyVelocity(H2DBody hBody, vec2 outVelocity);
76
77void Ph_GetDynamicBodyPosition(H2DBody hBody, vec2 outPos);
78
79void Ph_SetDynamicBodyPosition(H2DBody hBody, vec2 inPos);
80
81void Ph_UnpackShapeUserData(void* pUserData, HEntity2D* pOutEnt, u16* pOutCompIndex, u16* pOutBodyType);
82
83u64 Ph_PackShapeUserData(HEntity2D hEnt, u16 componentIndex, u16 bodyType);
84
85#endif
vec2 vec2 struct Entity2DCollection struct GameFrameworkLayer * pLayer
Definition EntityQuadTree.h:38
HGeneric H2DBody
Definition HandleDefs.h:42
HGeneric HEntity2D
Definition HandleDefs.h:38
HGeneric HPhysicsWorld
Definition HandleDefs.h:40
uint64_t u64
Definition IntTypes.h:15
uint16_t u16
Definition IntTypes.h:9
uint32_t u32
Definition IntTypes.h:12
H2DBody Ph_GetDynamicBody(HPhysicsWorld world, struct PhysicsShape2D *pShape, struct KinematicBodyOptions *pOptions, struct Transform2D *pTransform, HEntity2D entity, bool bIsSensor, int entityComponentIndex, bool bGenerateSensorEvents)
Definition Physics2D.c:257
void Ph_SetDynamicBodyPosition(H2DBody hBody, vec2 inPos)
Definition Physics2D.c:284
void Ph_GetDynamicBodyPosition(H2DBody hBody, vec2 outPos)
Definition Physics2D.c:277
void Ph_DestroyPhysicsWorld(HPhysicsWorld world)
float Ph_GetPixelsPerMeter(HPhysicsWorld world)
Definition Physics2D.c:123
HPhysicsWorld Ph_GetPhysicsWorld(float gravityX, float gravityY, float pixelsPerMeter)
Definition Physics2D.c:52
void Ph_PhysicsCoords2PixelCoords(HPhysicsWorld world, vec2 inPhysicsCoords, vec2 outPixelCoords)
Definition Physics2D.c:135
void Ph_PhysicsWorldStep(HPhysicsWorld hWorld, float timestep, int substepCount)
Definition Physics2D.c:66
vec2 Physics2DPoint
Definition Physics2D.h:9
void Ph_GetDynamicBodyVelocity(H2DBody hBody, vec2 outVelocity)
Definition Physics2D.c:269
void Ph_PixelCoords2PhysicsCoords(HPhysicsWorld world, vec2 inPixelCoords, vec2 outPhysicsCoords)
Definition Physics2D.c:128
u64 Ph_PackShapeUserData(HEntity2D hEnt, u16 componentIndex, u16 bodyType)
Definition Physics2D.c:142
void Ph_PhysicsWorldDoCollisionEvents(struct GameFrameworkLayer *pLayer)
Definition Physics2D.c:73
void Ph_Init()
Definition Physics2D.c:46
void Ph_SetDynamicBodyVelocity(H2DBody hBody, vec2 velocity)
Definition Physics2D.c:262
H2DBody Ph_GetStaticBody2D(HPhysicsWorld world, struct PhysicsShape2D *pShape, struct Transform2D *pTransform, HEntity2D entity, bool bIsSensor, int entityComponentIndex, bool bGenerateSensorEvents)
Definition Physics2D.c:252
PhysicsBodyType
Definition Physics2D.h:29
@ PBT_Circle
Definition Physics2D.h:31
@ PBT_Ellipse
Definition Physics2D.h:32
@ PBT_Poly
Definition Physics2D.h:33
@ PBT_Rect
Definition Physics2D.h:30
void Ph_UnpackShapeUserData(void *pUserData, HEntity2D *pOutEnt, u16 *pOutCompIndex, u16 *pOutBodyType)
Definition Physics2D.c:151
Definition GameFramework.h:42
Definition Physics2D.h:49
u32 bLockRotation
Definition Physics2D.h:50
Definition Physics2D.h:23
float radius
Definition Physics2D.h:25
vec2 center
Definition Physics2D.h:24
Definition Physics2D.h:18
VECTOR(Physics2DPoint) pPoints
Definition Physics2D.h:13
float w
Definition Physics2D.h:14
float h
Definition Physics2D.h:14
Definition Physics2D.h:38
struct Physics2DCircle circle
Definition Physics2D.h:42
enum PhysicsBodyType type
Definition Physics2D.h:39
struct Physics2DRect rect
Definition Physics2D.h:44
union PhysicsShape2D::@21 data
struct Physics2DPoly poly
Definition Physics2D.h:43
Definition Game2DLayer.h:55