Skip to content

Commit 67e6bf2

Browse files
add @victorfisac version of Physac
1 parent 5575f6b commit 67e6bf2

File tree

8 files changed

+144
-138
lines changed

8 files changed

+144
-138
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "raygui"]
55
path = raygui
66
url = https://github.com/raysan5/raygui.git
7+
[submodule "physac"]
8+
path = physac
9+
url = https://github.com/victorfisac/Physac

dynamic/raylib/__init__.pyi

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def CloseAudioDevice() -> None:
135135
...
136136
@deprecated("Raylib no longer recommends the use of Physac library")
137137
def ClosePhysics() -> None:
138-
"""Close physics system and unload used memory."""
138+
"""Unitializes physics pointers and closes physics loop thread."""
139139
...
140140
def CloseWindow() -> None:
141141
"""Close window and unload OpenGL context."""
@@ -216,7 +216,7 @@ def DecompressData(compData: bytes,compDataSize: int,dataSize: Any,) -> bytes:
216216
...
217217
@deprecated("Raylib no longer recommends the use of Physac library")
218218
def DestroyPhysicsBody(body: Any|list|tuple,) -> None:
219-
"""Destroy a physics body."""
219+
"""Unitializes and destroy a physics body."""
220220
...
221221
def DetachAudioMixedProcessor(processor: Any,) -> None:
222222
"""Detach audio stream processor from the entire audio pipeline."""
@@ -1605,7 +1605,7 @@ def InitAudioDevice() -> None:
16051605
...
16061606
@deprecated("Raylib no longer recommends the use of Physac library")
16071607
def InitPhysics() -> None:
1608-
"""Initializes physics system."""
1608+
"""Initializes physics values, pointers and creates physics loop thread."""
16091609
...
16101610
def InitWindow(width: int,height: int,title: bytes,) -> None:
16111611
"""Initialize window and OpenGL context."""
@@ -1706,6 +1706,10 @@ def IsMusicValid(music: Music|list|tuple,) -> bool:
17061706
def IsPathFile(path: bytes,) -> bool:
17071707
"""Check if a given path is a file or a directory."""
17081708
...
1709+
@deprecated("Raylib no longer recommends the use of Physac library")
1710+
def IsPhysicsEnabled() -> bool:
1711+
"""Returns true if physics thread is currently enabled."""
1712+
...
17091713
def IsRenderTextureValid(target: RenderTexture|list|tuple,) -> bool:
17101714
"""Check if a render texture is valid (loaded in GPU)."""
17111715
...
@@ -2389,10 +2393,6 @@ RL_TEXTURE_FILTER_TRILINEAR: int
23892393
def Remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
23902394
"""."""
23912395
...
2392-
@deprecated("Raylib no longer recommends the use of Physac library")
2393-
def ResetPhysics() -> None:
2394-
"""Reset physics system (global variables)."""
2395-
...
23962396
def RestoreWindow() -> None:
23972397
"""Set window state: not minimized/maximized."""
23982398
...
@@ -2405,6 +2405,10 @@ def ResumeMusicStream(music: Music|list|tuple,) -> None:
24052405
def ResumeSound(sound: Sound|list|tuple,) -> None:
24062406
"""Resume a paused sound."""
24072407
...
2408+
@deprecated("Raylib no longer recommends the use of Physac library")
2409+
def RunPhysicsStep() -> None:
2410+
"""Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop."""
2411+
...
24082412
SCROLLBAR: int
24092413
SCROLLBAR_SIDE: int
24102414
SCROLLBAR_WIDTH: int
@@ -2873,10 +2877,6 @@ def UpdateModelAnimationBones(model: Model|list|tuple,anim: ModelAnimation|list|
28732877
def UpdateMusicStream(music: Music|list|tuple,) -> None:
28742878
"""Updates buffers for music streaming."""
28752879
...
2876-
@deprecated("Raylib no longer recommends the use of Physac library")
2877-
def UpdatePhysics() -> None:
2878-
"""Update physics system."""
2879-
...
28802880
def UpdateSound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
28812881
"""Update sound buffer with new data."""
28822882
...
@@ -4131,6 +4131,11 @@ class Image:
41314131
mipmaps: int
41324132
format: int
41334133
KeyboardKey = int
4134+
class Mat2:
4135+
m00: float
4136+
m01: float
4137+
m10: float
4138+
m11: float
41344139
class Material:
41354140
shader: Shader
41364141
maps: Any
@@ -4157,11 +4162,6 @@ class Matrix:
41574162
m7: float
41584163
m11: float
41594164
m15: float
4160-
class Matrix2x2:
4161-
m00: float
4162-
m01: float
4163-
m10: float
4164-
m11: float
41654165
class Mesh:
41664166
vertexCount: int
41674167
triangleCount: int
@@ -4246,15 +4246,15 @@ class PhysicsManifoldData:
42464246
class PhysicsShape:
42474247
type: PhysicsShapeType
42484248
body: Any
4249-
vertexData: PhysicsVertexData
42504249
radius: float
4251-
transform: Matrix2x2
4250+
transform: Mat2
4251+
vertexData: PolygonData
42524252
PhysicsShapeType = int
4253-
class PhysicsVertexData:
4253+
PixelFormat = int
4254+
class PolygonData:
42544255
vertexCount: int
42554256
positions: list
42564257
normals: list
4257-
PixelFormat = int
42584258
class Quaternion:
42594259
x: float
42604260
y: float

dynamic/raylib/defines.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,10 @@
186186
PHYSAC_MAX_BODIES: int = 64
187187
PHYSAC_MAX_MANIFOLDS: int = 4096
188188
PHYSAC_MAX_VERTICES: int = 24
189-
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
190-
PHYSAC_COLLISION_ITERATIONS: int = 100
189+
PHYSAC_CIRCLE_VERTICES: int = 24
190+
PHYSAC_COLLISION_ITERATIONS: int = 20
191191
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
192192
PHYSAC_PENETRATION_CORRECTION: float = 0.4
193-
PHYSAC_PI: float = 3.141592653589793
194-
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
195193
PHYSAC_FLT_MAX: float = 3.402823466e+38
196194
PHYSAC_EPSILON: float = 1e-06
197195
GLFW_VERSION_MAJOR: int = 3

physac

Submodule physac added at 587b639

pyray/__init__.pyi

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ def close_audio_device() -> None:
995995
...
996996
@deprecated("Raylib no longer recommends the use of Physac library")
997997
def close_physics() -> None:
998-
"""Close physics system and unload used memory."""
998+
"""Unitializes physics pointers and closes physics loop thread."""
999999
...
10001000
def close_window() -> None:
10011001
"""Close window and unload OpenGL context."""
@@ -1071,7 +1071,7 @@ def decompress_data(compData: str,compDataSize: int,dataSize: Any,) -> str:
10711071
...
10721072
@deprecated("Raylib no longer recommends the use of Physac library")
10731073
def destroy_physics_body(body: Any|list|tuple,) -> None:
1074-
"""Destroy a physics body."""
1074+
"""Unitializes and destroy a physics body."""
10751075
...
10761076
def detach_audio_mixed_processor(processor: Any,) -> None:
10771077
"""Detach audio stream processor from the entire audio pipeline."""
@@ -2145,7 +2145,7 @@ def init_audio_device() -> None:
21452145
...
21462146
@deprecated("Raylib no longer recommends the use of Physac library")
21472147
def init_physics() -> None:
2148-
"""Initializes physics system."""
2148+
"""Initializes physics values, pointers and creates physics loop thread."""
21492149
...
21502150
def init_window(width: int,height: int,title: str,) -> None:
21512151
"""Initialize window and OpenGL context."""
@@ -2246,6 +2246,10 @@ def is_music_valid(music: Music|list|tuple,) -> bool:
22462246
def is_path_file(path: str,) -> bool:
22472247
"""Check if a given path is a file or a directory."""
22482248
...
2249+
@deprecated("Raylib no longer recommends the use of Physac library")
2250+
def is_physics_enabled() -> bool:
2251+
"""Returns true if physics thread is currently enabled."""
2252+
...
22492253
def is_render_texture_valid(target: RenderTexture|list|tuple,) -> bool:
22502254
"""Check if a render texture is valid (loaded in GPU)."""
22512255
...
@@ -2630,10 +2634,6 @@ def quaternion_transform(q: Vector4|list|tuple,mat: Matrix|list|tuple,) -> Vecto
26302634
def remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
26312635
"""."""
26322636
...
2633-
@deprecated("Raylib no longer recommends the use of Physac library")
2634-
def reset_physics() -> None:
2635-
"""Reset physics system (global variables)."""
2636-
...
26372637
def restore_window() -> None:
26382638
"""Set window state: not minimized/maximized."""
26392639
...
@@ -2646,6 +2646,10 @@ def resume_music_stream(music: Music|list|tuple,) -> None:
26462646
def resume_sound(sound: Sound|list|tuple,) -> None:
26472647
"""Resume a paused sound."""
26482648
...
2649+
@deprecated("Raylib no longer recommends the use of Physac library")
2650+
def run_physics_step() -> None:
2651+
"""Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop."""
2652+
...
26492653
def save_file_data(fileName: str,data: Any,dataSize: int,) -> bool:
26502654
"""Save data to file from byte array (write), returns true on success."""
26512655
...
@@ -3021,10 +3025,6 @@ def update_model_animation_bones(model: Model|list|tuple,anim: ModelAnimation|li
30213025
def update_music_stream(music: Music|list|tuple,) -> None:
30223026
"""Updates buffers for music streaming."""
30233027
...
3024-
@deprecated("Raylib no longer recommends the use of Physac library")
3025-
def update_physics() -> None:
3026-
"""Update physics system."""
3027-
...
30283028
def update_sound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
30293029
"""Update sound buffer with new data."""
30303030
...
@@ -4239,6 +4239,13 @@ class Image:
42394239
self.height:int = height # type: ignore
42404240
self.mipmaps:int = mipmaps # type: ignore
42414241
self.format:int = format # type: ignore
4242+
class Mat2:
4243+
"""Mat2 type (used for polygon shape rotation matrix)."""
4244+
def __init__(self, m00: float|None = None, m01: float|None = None, m10: float|None = None, m11: float|None = None):
4245+
self.m00:float = m00 # type: ignore
4246+
self.m01:float = m01 # type: ignore
4247+
self.m10:float = m10 # type: ignore
4248+
self.m11:float = m11 # type: ignore
42424249
class Material:
42434250
"""Material, includes shader and maps."""
42444251
def __init__(self, shader: Shader|list|tuple|None = None, maps: Any|None = None, params: list|None = None):
@@ -4270,13 +4277,6 @@ class Matrix:
42704277
self.m7:float = m7 # type: ignore
42714278
self.m11:float = m11 # type: ignore
42724279
self.m15:float = m15 # type: ignore
4273-
class Matrix2x2:
4274-
"""Matrix2x2 type (used for polygon shape rotation matrix)."""
4275-
def __init__(self, m00: float|None = None, m01: float|None = None, m10: float|None = None, m11: float|None = None):
4276-
self.m00:float = m00 # type: ignore
4277-
self.m01:float = m01 # type: ignore
4278-
self.m10:float = m10 # type: ignore
4279-
self.m11:float = m11 # type: ignore
42804280
class Mesh:
42814281
"""Mesh, vertex data and vao/vbo."""
42824282
def __init__(self, vertexCount: int|None = None, triangleCount: int|None = None, vertices: Any|None = None, texcoords: Any|None = None, texcoords2: Any|None = None, normals: Any|None = None, tangents: Any|None = None, colors: str|None = None, indices: Any|None = None, animVertices: Any|None = None, animNormals: Any|None = None, boneIds: str|None = None, boneWeights: Any|None = None, boneMatrices: Any|None = None, boneCount: int|None = None, vaoId: int|None = None, vboId: Any|None = None):
@@ -4371,13 +4371,13 @@ class PhysicsManifoldData:
43714371
self.staticFriction:float = staticFriction # type: ignore
43724372
class PhysicsShape:
43734373
"""."""
4374-
def __init__(self, type: PhysicsShapeType|None = None, body: Any|None = None, vertexData: PhysicsVertexData|list|tuple|None = None, radius: float|None = None, transform: Matrix2x2|list|tuple|None = None):
4374+
def __init__(self, type: PhysicsShapeType|None = None, body: Any|None = None, radius: float|None = None, transform: Mat2|list|tuple|None = None, vertexData: PolygonData|list|tuple|None = None):
43754375
self.type:PhysicsShapeType = type # type: ignore
43764376
self.body:Any = body # type: ignore
4377-
self.vertexData:PhysicsVertexData = vertexData # type: ignore
43784377
self.radius:float = radius # type: ignore
4379-
self.transform:Matrix2x2 = transform # type: ignore
4380-
class PhysicsVertexData:
4378+
self.transform:Mat2 = transform # type: ignore
4379+
self.vertexData:PolygonData = vertexData # type: ignore
4380+
class PolygonData:
43814381
"""."""
43824382
def __init__(self, vertexCount: int|None = None, positions: list|None = None, normals: list|None = None):
43834383
self.vertexCount:int = vertexCount # type: ignore

raylib/__init__.pyi

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def CloseAudioDevice() -> None:
135135
...
136136
@deprecated("Raylib no longer recommends the use of Physac library")
137137
def ClosePhysics() -> None:
138-
"""Close physics system and unload used memory."""
138+
"""Unitializes physics pointers and closes physics loop thread."""
139139
...
140140
def CloseWindow() -> None:
141141
"""Close window and unload OpenGL context."""
@@ -216,7 +216,7 @@ def DecompressData(compData: bytes,compDataSize: int,dataSize: Any,) -> bytes:
216216
...
217217
@deprecated("Raylib no longer recommends the use of Physac library")
218218
def DestroyPhysicsBody(body: Any|list|tuple,) -> None:
219-
"""Destroy a physics body."""
219+
"""Unitializes and destroy a physics body."""
220220
...
221221
def DetachAudioMixedProcessor(processor: Any,) -> None:
222222
"""Detach audio stream processor from the entire audio pipeline."""
@@ -1605,7 +1605,7 @@ def InitAudioDevice() -> None:
16051605
...
16061606
@deprecated("Raylib no longer recommends the use of Physac library")
16071607
def InitPhysics() -> None:
1608-
"""Initializes physics system."""
1608+
"""Initializes physics values, pointers and creates physics loop thread."""
16091609
...
16101610
def InitWindow(width: int,height: int,title: bytes,) -> None:
16111611
"""Initialize window and OpenGL context."""
@@ -1706,6 +1706,10 @@ def IsMusicValid(music: Music|list|tuple,) -> bool:
17061706
def IsPathFile(path: bytes,) -> bool:
17071707
"""Check if a given path is a file or a directory."""
17081708
...
1709+
@deprecated("Raylib no longer recommends the use of Physac library")
1710+
def IsPhysicsEnabled() -> bool:
1711+
"""Returns true if physics thread is currently enabled."""
1712+
...
17091713
def IsRenderTextureValid(target: RenderTexture|list|tuple,) -> bool:
17101714
"""Check if a render texture is valid (loaded in GPU)."""
17111715
...
@@ -2389,10 +2393,6 @@ RL_TEXTURE_FILTER_TRILINEAR: int
23892393
def Remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
23902394
"""."""
23912395
...
2392-
@deprecated("Raylib no longer recommends the use of Physac library")
2393-
def ResetPhysics() -> None:
2394-
"""Reset physics system (global variables)."""
2395-
...
23962396
def RestoreWindow() -> None:
23972397
"""Set window state: not minimized/maximized."""
23982398
...
@@ -2405,6 +2405,10 @@ def ResumeMusicStream(music: Music|list|tuple,) -> None:
24052405
def ResumeSound(sound: Sound|list|tuple,) -> None:
24062406
"""Resume a paused sound."""
24072407
...
2408+
@deprecated("Raylib no longer recommends the use of Physac library")
2409+
def RunPhysicsStep() -> None:
2410+
"""Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop."""
2411+
...
24082412
SCROLLBAR: int
24092413
SCROLLBAR_SIDE: int
24102414
SCROLLBAR_WIDTH: int
@@ -2873,10 +2877,6 @@ def UpdateModelAnimationBones(model: Model|list|tuple,anim: ModelAnimation|list|
28732877
def UpdateMusicStream(music: Music|list|tuple,) -> None:
28742878
"""Updates buffers for music streaming."""
28752879
...
2876-
@deprecated("Raylib no longer recommends the use of Physac library")
2877-
def UpdatePhysics() -> None:
2878-
"""Update physics system."""
2879-
...
28802880
def UpdateSound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
28812881
"""Update sound buffer with new data."""
28822882
...
@@ -4131,6 +4131,11 @@ class Image:
41314131
mipmaps: int
41324132
format: int
41334133
KeyboardKey = int
4134+
class Mat2:
4135+
m00: float
4136+
m01: float
4137+
m10: float
4138+
m11: float
41344139
class Material:
41354140
shader: Shader
41364141
maps: Any
@@ -4157,11 +4162,6 @@ class Matrix:
41574162
m7: float
41584163
m11: float
41594164
m15: float
4160-
class Matrix2x2:
4161-
m00: float
4162-
m01: float
4163-
m10: float
4164-
m11: float
41654165
class Mesh:
41664166
vertexCount: int
41674167
triangleCount: int
@@ -4246,15 +4246,15 @@ class PhysicsManifoldData:
42464246
class PhysicsShape:
42474247
type: PhysicsShapeType
42484248
body: Any
4249-
vertexData: PhysicsVertexData
42504249
radius: float
4251-
transform: Matrix2x2
4250+
transform: Mat2
4251+
vertexData: PolygonData
42524252
PhysicsShapeType = int
4253-
class PhysicsVertexData:
4253+
PixelFormat = int
4254+
class PolygonData:
42544255
vertexCount: int
42554256
positions: list
42564257
normals: list
4257-
PixelFormat = int
42584258
class Quaternion:
42594259
x: float
42604260
y: float

raylib/defines.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,10 @@
186186
PHYSAC_MAX_BODIES: int = 64
187187
PHYSAC_MAX_MANIFOLDS: int = 4096
188188
PHYSAC_MAX_VERTICES: int = 24
189-
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
190-
PHYSAC_COLLISION_ITERATIONS: int = 100
189+
PHYSAC_CIRCLE_VERTICES: int = 24
190+
PHYSAC_COLLISION_ITERATIONS: int = 20
191191
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
192192
PHYSAC_PENETRATION_CORRECTION: float = 0.4
193-
PHYSAC_PI: float = 3.141592653589793
194-
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
195193
PHYSAC_FLT_MAX: float = 3.402823466e+38
196194
PHYSAC_EPSILON: float = 1e-06
197195
GLFW_VERSION_MAJOR: int = 3

0 commit comments

Comments
 (0)