add @victorfisac version of Physac
This commit is contained in:
parent
5575f6b7b0
commit
67e6bf2405
8 changed files with 144 additions and 138 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -4,3 +4,6 @@
|
||||||
[submodule "raygui"]
|
[submodule "raygui"]
|
||||||
path = raygui
|
path = raygui
|
||||||
url = https://github.com/raysan5/raygui.git
|
url = https://github.com/raysan5/raygui.git
|
||||||
|
[submodule "physac"]
|
||||||
|
path = physac
|
||||||
|
url = https://github.com/victorfisac/Physac
|
||||||
|
|
|
@ -135,7 +135,7 @@ def CloseAudioDevice() -> None:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def ClosePhysics() -> None:
|
def ClosePhysics() -> None:
|
||||||
"""Close physics system and unload used memory."""
|
"""Unitializes physics pointers and closes physics loop thread."""
|
||||||
...
|
...
|
||||||
def CloseWindow() -> None:
|
def CloseWindow() -> None:
|
||||||
"""Close window and unload OpenGL context."""
|
"""Close window and unload OpenGL context."""
|
||||||
|
@ -216,7 +216,7 @@ def DecompressData(compData: bytes,compDataSize: int,dataSize: Any,) -> bytes:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def DestroyPhysicsBody(body: Any|list|tuple,) -> None:
|
def DestroyPhysicsBody(body: Any|list|tuple,) -> None:
|
||||||
"""Destroy a physics body."""
|
"""Unitializes and destroy a physics body."""
|
||||||
...
|
...
|
||||||
def DetachAudioMixedProcessor(processor: Any,) -> None:
|
def DetachAudioMixedProcessor(processor: Any,) -> None:
|
||||||
"""Detach audio stream processor from the entire audio pipeline."""
|
"""Detach audio stream processor from the entire audio pipeline."""
|
||||||
|
@ -1605,7 +1605,7 @@ def InitAudioDevice() -> None:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def InitPhysics() -> None:
|
def InitPhysics() -> None:
|
||||||
"""Initializes physics system."""
|
"""Initializes physics values, pointers and creates physics loop thread."""
|
||||||
...
|
...
|
||||||
def InitWindow(width: int,height: int,title: bytes,) -> None:
|
def InitWindow(width: int,height: int,title: bytes,) -> None:
|
||||||
"""Initialize window and OpenGL context."""
|
"""Initialize window and OpenGL context."""
|
||||||
|
@ -1706,6 +1706,10 @@ def IsMusicValid(music: Music|list|tuple,) -> bool:
|
||||||
def IsPathFile(path: bytes,) -> bool:
|
def IsPathFile(path: bytes,) -> bool:
|
||||||
"""Check if a given path is a file or a directory."""
|
"""Check if a given path is a file or a directory."""
|
||||||
...
|
...
|
||||||
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
|
def IsPhysicsEnabled() -> bool:
|
||||||
|
"""Returns true if physics thread is currently enabled."""
|
||||||
|
...
|
||||||
def IsRenderTextureValid(target: RenderTexture|list|tuple,) -> bool:
|
def IsRenderTextureValid(target: RenderTexture|list|tuple,) -> bool:
|
||||||
"""Check if a render texture is valid (loaded in GPU)."""
|
"""Check if a render texture is valid (loaded in GPU)."""
|
||||||
...
|
...
|
||||||
|
@ -2389,10 +2393,6 @@ RL_TEXTURE_FILTER_TRILINEAR: int
|
||||||
def Remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
|
def Remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
|
||||||
"""."""
|
"""."""
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
|
||||||
def ResetPhysics() -> None:
|
|
||||||
"""Reset physics system (global variables)."""
|
|
||||||
...
|
|
||||||
def RestoreWindow() -> None:
|
def RestoreWindow() -> None:
|
||||||
"""Set window state: not minimized/maximized."""
|
"""Set window state: not minimized/maximized."""
|
||||||
...
|
...
|
||||||
|
@ -2405,6 +2405,10 @@ def ResumeMusicStream(music: Music|list|tuple,) -> None:
|
||||||
def ResumeSound(sound: Sound|list|tuple,) -> None:
|
def ResumeSound(sound: Sound|list|tuple,) -> None:
|
||||||
"""Resume a paused sound."""
|
"""Resume a paused sound."""
|
||||||
...
|
...
|
||||||
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
|
def RunPhysicsStep() -> None:
|
||||||
|
"""Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop."""
|
||||||
|
...
|
||||||
SCROLLBAR: int
|
SCROLLBAR: int
|
||||||
SCROLLBAR_SIDE: int
|
SCROLLBAR_SIDE: int
|
||||||
SCROLLBAR_WIDTH: int
|
SCROLLBAR_WIDTH: int
|
||||||
|
@ -2873,10 +2877,6 @@ def UpdateModelAnimationBones(model: Model|list|tuple,anim: ModelAnimation|list|
|
||||||
def UpdateMusicStream(music: Music|list|tuple,) -> None:
|
def UpdateMusicStream(music: Music|list|tuple,) -> None:
|
||||||
"""Updates buffers for music streaming."""
|
"""Updates buffers for music streaming."""
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
|
||||||
def UpdatePhysics() -> None:
|
|
||||||
"""Update physics system."""
|
|
||||||
...
|
|
||||||
def UpdateSound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
|
def UpdateSound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
|
||||||
"""Update sound buffer with new data."""
|
"""Update sound buffer with new data."""
|
||||||
...
|
...
|
||||||
|
@ -4131,6 +4131,11 @@ class Image:
|
||||||
mipmaps: int
|
mipmaps: int
|
||||||
format: int
|
format: int
|
||||||
KeyboardKey = int
|
KeyboardKey = int
|
||||||
|
class Mat2:
|
||||||
|
m00: float
|
||||||
|
m01: float
|
||||||
|
m10: float
|
||||||
|
m11: float
|
||||||
class Material:
|
class Material:
|
||||||
shader: Shader
|
shader: Shader
|
||||||
maps: Any
|
maps: Any
|
||||||
|
@ -4157,11 +4162,6 @@ class Matrix:
|
||||||
m7: float
|
m7: float
|
||||||
m11: float
|
m11: float
|
||||||
m15: float
|
m15: float
|
||||||
class Matrix2x2:
|
|
||||||
m00: float
|
|
||||||
m01: float
|
|
||||||
m10: float
|
|
||||||
m11: float
|
|
||||||
class Mesh:
|
class Mesh:
|
||||||
vertexCount: int
|
vertexCount: int
|
||||||
triangleCount: int
|
triangleCount: int
|
||||||
|
@ -4246,15 +4246,15 @@ class PhysicsManifoldData:
|
||||||
class PhysicsShape:
|
class PhysicsShape:
|
||||||
type: PhysicsShapeType
|
type: PhysicsShapeType
|
||||||
body: Any
|
body: Any
|
||||||
vertexData: PhysicsVertexData
|
|
||||||
radius: float
|
radius: float
|
||||||
transform: Matrix2x2
|
transform: Mat2
|
||||||
|
vertexData: PolygonData
|
||||||
PhysicsShapeType = int
|
PhysicsShapeType = int
|
||||||
class PhysicsVertexData:
|
PixelFormat = int
|
||||||
|
class PolygonData:
|
||||||
vertexCount: int
|
vertexCount: int
|
||||||
positions: list
|
positions: list
|
||||||
normals: list
|
normals: list
|
||||||
PixelFormat = int
|
|
||||||
class Quaternion:
|
class Quaternion:
|
||||||
x: float
|
x: float
|
||||||
y: float
|
y: float
|
||||||
|
|
|
@ -186,12 +186,10 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
|
||||||
PHYSAC_MAX_BODIES: int = 64
|
PHYSAC_MAX_BODIES: int = 64
|
||||||
PHYSAC_MAX_MANIFOLDS: int = 4096
|
PHYSAC_MAX_MANIFOLDS: int = 4096
|
||||||
PHYSAC_MAX_VERTICES: int = 24
|
PHYSAC_MAX_VERTICES: int = 24
|
||||||
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
|
PHYSAC_CIRCLE_VERTICES: int = 24
|
||||||
PHYSAC_COLLISION_ITERATIONS: int = 100
|
PHYSAC_COLLISION_ITERATIONS: int = 20
|
||||||
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
||||||
PHYSAC_PENETRATION_CORRECTION: float = 0.4
|
PHYSAC_PENETRATION_CORRECTION: float = 0.4
|
||||||
PHYSAC_PI: float = 3.141592653589793
|
|
||||||
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
|
|
||||||
PHYSAC_FLT_MAX: float = 3.402823466e+38
|
PHYSAC_FLT_MAX: float = 3.402823466e+38
|
||||||
PHYSAC_EPSILON: float = 1e-06
|
PHYSAC_EPSILON: float = 1e-06
|
||||||
GLFW_VERSION_MAJOR: int = 3
|
GLFW_VERSION_MAJOR: int = 3
|
||||||
|
|
1
physac
Submodule
1
physac
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 587b63926010593eedf29ef74e3aa22c1a507925
|
|
@ -995,7 +995,7 @@ def close_audio_device() -> None:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def close_physics() -> None:
|
def close_physics() -> None:
|
||||||
"""Close physics system and unload used memory."""
|
"""Unitializes physics pointers and closes physics loop thread."""
|
||||||
...
|
...
|
||||||
def close_window() -> None:
|
def close_window() -> None:
|
||||||
"""Close window and unload OpenGL context."""
|
"""Close window and unload OpenGL context."""
|
||||||
|
@ -1071,7 +1071,7 @@ def decompress_data(compData: str,compDataSize: int,dataSize: Any,) -> str:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def destroy_physics_body(body: Any|list|tuple,) -> None:
|
def destroy_physics_body(body: Any|list|tuple,) -> None:
|
||||||
"""Destroy a physics body."""
|
"""Unitializes and destroy a physics body."""
|
||||||
...
|
...
|
||||||
def detach_audio_mixed_processor(processor: Any,) -> None:
|
def detach_audio_mixed_processor(processor: Any,) -> None:
|
||||||
"""Detach audio stream processor from the entire audio pipeline."""
|
"""Detach audio stream processor from the entire audio pipeline."""
|
||||||
|
@ -2145,7 +2145,7 @@ def init_audio_device() -> None:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def init_physics() -> None:
|
def init_physics() -> None:
|
||||||
"""Initializes physics system."""
|
"""Initializes physics values, pointers and creates physics loop thread."""
|
||||||
...
|
...
|
||||||
def init_window(width: int,height: int,title: str,) -> None:
|
def init_window(width: int,height: int,title: str,) -> None:
|
||||||
"""Initialize window and OpenGL context."""
|
"""Initialize window and OpenGL context."""
|
||||||
|
@ -2246,6 +2246,10 @@ def is_music_valid(music: Music|list|tuple,) -> bool:
|
||||||
def is_path_file(path: str,) -> bool:
|
def is_path_file(path: str,) -> bool:
|
||||||
"""Check if a given path is a file or a directory."""
|
"""Check if a given path is a file or a directory."""
|
||||||
...
|
...
|
||||||
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
|
def is_physics_enabled() -> bool:
|
||||||
|
"""Returns true if physics thread is currently enabled."""
|
||||||
|
...
|
||||||
def is_render_texture_valid(target: RenderTexture|list|tuple,) -> bool:
|
def is_render_texture_valid(target: RenderTexture|list|tuple,) -> bool:
|
||||||
"""Check if a render texture is valid (loaded in GPU)."""
|
"""Check if a render texture is valid (loaded in GPU)."""
|
||||||
...
|
...
|
||||||
|
@ -2630,10 +2634,6 @@ def quaternion_transform(q: Vector4|list|tuple,mat: Matrix|list|tuple,) -> Vecto
|
||||||
def remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
|
def remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
|
||||||
"""."""
|
"""."""
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
|
||||||
def reset_physics() -> None:
|
|
||||||
"""Reset physics system (global variables)."""
|
|
||||||
...
|
|
||||||
def restore_window() -> None:
|
def restore_window() -> None:
|
||||||
"""Set window state: not minimized/maximized."""
|
"""Set window state: not minimized/maximized."""
|
||||||
...
|
...
|
||||||
|
@ -2646,6 +2646,10 @@ def resume_music_stream(music: Music|list|tuple,) -> None:
|
||||||
def resume_sound(sound: Sound|list|tuple,) -> None:
|
def resume_sound(sound: Sound|list|tuple,) -> None:
|
||||||
"""Resume a paused sound."""
|
"""Resume a paused sound."""
|
||||||
...
|
...
|
||||||
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
|
def run_physics_step() -> None:
|
||||||
|
"""Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop."""
|
||||||
|
...
|
||||||
def save_file_data(fileName: str,data: Any,dataSize: int,) -> bool:
|
def save_file_data(fileName: str,data: Any,dataSize: int,) -> bool:
|
||||||
"""Save data to file from byte array (write), returns true on success."""
|
"""Save data to file from byte array (write), returns true on success."""
|
||||||
...
|
...
|
||||||
|
@ -3021,10 +3025,6 @@ def update_model_animation_bones(model: Model|list|tuple,anim: ModelAnimation|li
|
||||||
def update_music_stream(music: Music|list|tuple,) -> None:
|
def update_music_stream(music: Music|list|tuple,) -> None:
|
||||||
"""Updates buffers for music streaming."""
|
"""Updates buffers for music streaming."""
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
|
||||||
def update_physics() -> None:
|
|
||||||
"""Update physics system."""
|
|
||||||
...
|
|
||||||
def update_sound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
|
def update_sound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
|
||||||
"""Update sound buffer with new data."""
|
"""Update sound buffer with new data."""
|
||||||
...
|
...
|
||||||
|
@ -4239,6 +4239,13 @@ class Image:
|
||||||
self.height:int = height # type: ignore
|
self.height:int = height # type: ignore
|
||||||
self.mipmaps:int = mipmaps # type: ignore
|
self.mipmaps:int = mipmaps # type: ignore
|
||||||
self.format:int = format # type: ignore
|
self.format:int = format # type: ignore
|
||||||
|
class Mat2:
|
||||||
|
"""Mat2 type (used for polygon shape rotation matrix)."""
|
||||||
|
def __init__(self, m00: float|None = None, m01: float|None = None, m10: float|None = None, m11: float|None = None):
|
||||||
|
self.m00:float = m00 # type: ignore
|
||||||
|
self.m01:float = m01 # type: ignore
|
||||||
|
self.m10:float = m10 # type: ignore
|
||||||
|
self.m11:float = m11 # type: ignore
|
||||||
class Material:
|
class Material:
|
||||||
"""Material, includes shader and maps."""
|
"""Material, includes shader and maps."""
|
||||||
def __init__(self, shader: Shader|list|tuple|None = None, maps: Any|None = None, params: list|None = None):
|
def __init__(self, shader: Shader|list|tuple|None = None, maps: Any|None = None, params: list|None = None):
|
||||||
|
@ -4270,13 +4277,6 @@ class Matrix:
|
||||||
self.m7:float = m7 # type: ignore
|
self.m7:float = m7 # type: ignore
|
||||||
self.m11:float = m11 # type: ignore
|
self.m11:float = m11 # type: ignore
|
||||||
self.m15:float = m15 # type: ignore
|
self.m15:float = m15 # type: ignore
|
||||||
class Matrix2x2:
|
|
||||||
"""Matrix2x2 type (used for polygon shape rotation matrix)."""
|
|
||||||
def __init__(self, m00: float|None = None, m01: float|None = None, m10: float|None = None, m11: float|None = None):
|
|
||||||
self.m00:float = m00 # type: ignore
|
|
||||||
self.m01:float = m01 # type: ignore
|
|
||||||
self.m10:float = m10 # type: ignore
|
|
||||||
self.m11:float = m11 # type: ignore
|
|
||||||
class Mesh:
|
class Mesh:
|
||||||
"""Mesh, vertex data and vao/vbo."""
|
"""Mesh, vertex data and vao/vbo."""
|
||||||
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):
|
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:
|
||||||
self.staticFriction:float = staticFriction # type: ignore
|
self.staticFriction:float = staticFriction # type: ignore
|
||||||
class PhysicsShape:
|
class PhysicsShape:
|
||||||
"""."""
|
"""."""
|
||||||
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):
|
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):
|
||||||
self.type:PhysicsShapeType = type # type: ignore
|
self.type:PhysicsShapeType = type # type: ignore
|
||||||
self.body:Any = body # type: ignore
|
self.body:Any = body # type: ignore
|
||||||
self.vertexData:PhysicsVertexData = vertexData # type: ignore
|
|
||||||
self.radius:float = radius # type: ignore
|
self.radius:float = radius # type: ignore
|
||||||
self.transform:Matrix2x2 = transform # type: ignore
|
self.transform:Mat2 = transform # type: ignore
|
||||||
class PhysicsVertexData:
|
self.vertexData:PolygonData = vertexData # type: ignore
|
||||||
|
class PolygonData:
|
||||||
"""."""
|
"""."""
|
||||||
def __init__(self, vertexCount: int|None = None, positions: list|None = None, normals: list|None = None):
|
def __init__(self, vertexCount: int|None = None, positions: list|None = None, normals: list|None = None):
|
||||||
self.vertexCount:int = vertexCount # type: ignore
|
self.vertexCount:int = vertexCount # type: ignore
|
||||||
|
|
|
@ -135,7 +135,7 @@ def CloseAudioDevice() -> None:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def ClosePhysics() -> None:
|
def ClosePhysics() -> None:
|
||||||
"""Close physics system and unload used memory."""
|
"""Unitializes physics pointers and closes physics loop thread."""
|
||||||
...
|
...
|
||||||
def CloseWindow() -> None:
|
def CloseWindow() -> None:
|
||||||
"""Close window and unload OpenGL context."""
|
"""Close window and unload OpenGL context."""
|
||||||
|
@ -216,7 +216,7 @@ def DecompressData(compData: bytes,compDataSize: int,dataSize: Any,) -> bytes:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def DestroyPhysicsBody(body: Any|list|tuple,) -> None:
|
def DestroyPhysicsBody(body: Any|list|tuple,) -> None:
|
||||||
"""Destroy a physics body."""
|
"""Unitializes and destroy a physics body."""
|
||||||
...
|
...
|
||||||
def DetachAudioMixedProcessor(processor: Any,) -> None:
|
def DetachAudioMixedProcessor(processor: Any,) -> None:
|
||||||
"""Detach audio stream processor from the entire audio pipeline."""
|
"""Detach audio stream processor from the entire audio pipeline."""
|
||||||
|
@ -1605,7 +1605,7 @@ def InitAudioDevice() -> None:
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
def InitPhysics() -> None:
|
def InitPhysics() -> None:
|
||||||
"""Initializes physics system."""
|
"""Initializes physics values, pointers and creates physics loop thread."""
|
||||||
...
|
...
|
||||||
def InitWindow(width: int,height: int,title: bytes,) -> None:
|
def InitWindow(width: int,height: int,title: bytes,) -> None:
|
||||||
"""Initialize window and OpenGL context."""
|
"""Initialize window and OpenGL context."""
|
||||||
|
@ -1706,6 +1706,10 @@ def IsMusicValid(music: Music|list|tuple,) -> bool:
|
||||||
def IsPathFile(path: bytes,) -> bool:
|
def IsPathFile(path: bytes,) -> bool:
|
||||||
"""Check if a given path is a file or a directory."""
|
"""Check if a given path is a file or a directory."""
|
||||||
...
|
...
|
||||||
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
|
def IsPhysicsEnabled() -> bool:
|
||||||
|
"""Returns true if physics thread is currently enabled."""
|
||||||
|
...
|
||||||
def IsRenderTextureValid(target: RenderTexture|list|tuple,) -> bool:
|
def IsRenderTextureValid(target: RenderTexture|list|tuple,) -> bool:
|
||||||
"""Check if a render texture is valid (loaded in GPU)."""
|
"""Check if a render texture is valid (loaded in GPU)."""
|
||||||
...
|
...
|
||||||
|
@ -2389,10 +2393,6 @@ RL_TEXTURE_FILTER_TRILINEAR: int
|
||||||
def Remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
|
def Remap(value: float,inputStart: float,inputEnd: float,outputStart: float,outputEnd: float,) -> float:
|
||||||
"""."""
|
"""."""
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
|
||||||
def ResetPhysics() -> None:
|
|
||||||
"""Reset physics system (global variables)."""
|
|
||||||
...
|
|
||||||
def RestoreWindow() -> None:
|
def RestoreWindow() -> None:
|
||||||
"""Set window state: not minimized/maximized."""
|
"""Set window state: not minimized/maximized."""
|
||||||
...
|
...
|
||||||
|
@ -2405,6 +2405,10 @@ def ResumeMusicStream(music: Music|list|tuple,) -> None:
|
||||||
def ResumeSound(sound: Sound|list|tuple,) -> None:
|
def ResumeSound(sound: Sound|list|tuple,) -> None:
|
||||||
"""Resume a paused sound."""
|
"""Resume a paused sound."""
|
||||||
...
|
...
|
||||||
|
@deprecated("Raylib no longer recommends the use of Physac library")
|
||||||
|
def RunPhysicsStep() -> None:
|
||||||
|
"""Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop."""
|
||||||
|
...
|
||||||
SCROLLBAR: int
|
SCROLLBAR: int
|
||||||
SCROLLBAR_SIDE: int
|
SCROLLBAR_SIDE: int
|
||||||
SCROLLBAR_WIDTH: int
|
SCROLLBAR_WIDTH: int
|
||||||
|
@ -2873,10 +2877,6 @@ def UpdateModelAnimationBones(model: Model|list|tuple,anim: ModelAnimation|list|
|
||||||
def UpdateMusicStream(music: Music|list|tuple,) -> None:
|
def UpdateMusicStream(music: Music|list|tuple,) -> None:
|
||||||
"""Updates buffers for music streaming."""
|
"""Updates buffers for music streaming."""
|
||||||
...
|
...
|
||||||
@deprecated("Raylib no longer recommends the use of Physac library")
|
|
||||||
def UpdatePhysics() -> None:
|
|
||||||
"""Update physics system."""
|
|
||||||
...
|
|
||||||
def UpdateSound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
|
def UpdateSound(sound: Sound|list|tuple,data: Any,sampleCount: int,) -> None:
|
||||||
"""Update sound buffer with new data."""
|
"""Update sound buffer with new data."""
|
||||||
...
|
...
|
||||||
|
@ -4131,6 +4131,11 @@ class Image:
|
||||||
mipmaps: int
|
mipmaps: int
|
||||||
format: int
|
format: int
|
||||||
KeyboardKey = int
|
KeyboardKey = int
|
||||||
|
class Mat2:
|
||||||
|
m00: float
|
||||||
|
m01: float
|
||||||
|
m10: float
|
||||||
|
m11: float
|
||||||
class Material:
|
class Material:
|
||||||
shader: Shader
|
shader: Shader
|
||||||
maps: Any
|
maps: Any
|
||||||
|
@ -4157,11 +4162,6 @@ class Matrix:
|
||||||
m7: float
|
m7: float
|
||||||
m11: float
|
m11: float
|
||||||
m15: float
|
m15: float
|
||||||
class Matrix2x2:
|
|
||||||
m00: float
|
|
||||||
m01: float
|
|
||||||
m10: float
|
|
||||||
m11: float
|
|
||||||
class Mesh:
|
class Mesh:
|
||||||
vertexCount: int
|
vertexCount: int
|
||||||
triangleCount: int
|
triangleCount: int
|
||||||
|
@ -4246,15 +4246,15 @@ class PhysicsManifoldData:
|
||||||
class PhysicsShape:
|
class PhysicsShape:
|
||||||
type: PhysicsShapeType
|
type: PhysicsShapeType
|
||||||
body: Any
|
body: Any
|
||||||
vertexData: PhysicsVertexData
|
|
||||||
radius: float
|
radius: float
|
||||||
transform: Matrix2x2
|
transform: Mat2
|
||||||
|
vertexData: PolygonData
|
||||||
PhysicsShapeType = int
|
PhysicsShapeType = int
|
||||||
class PhysicsVertexData:
|
PixelFormat = int
|
||||||
|
class PolygonData:
|
||||||
vertexCount: int
|
vertexCount: int
|
||||||
positions: list
|
positions: list
|
||||||
normals: list
|
normals: list
|
||||||
PixelFormat = int
|
|
||||||
class Quaternion:
|
class Quaternion:
|
||||||
x: float
|
x: float
|
||||||
y: float
|
y: float
|
||||||
|
|
|
@ -186,12 +186,10 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
|
||||||
PHYSAC_MAX_BODIES: int = 64
|
PHYSAC_MAX_BODIES: int = 64
|
||||||
PHYSAC_MAX_MANIFOLDS: int = 4096
|
PHYSAC_MAX_MANIFOLDS: int = 4096
|
||||||
PHYSAC_MAX_VERTICES: int = 24
|
PHYSAC_MAX_VERTICES: int = 24
|
||||||
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
|
PHYSAC_CIRCLE_VERTICES: int = 24
|
||||||
PHYSAC_COLLISION_ITERATIONS: int = 100
|
PHYSAC_COLLISION_ITERATIONS: int = 20
|
||||||
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
||||||
PHYSAC_PENETRATION_CORRECTION: float = 0.4
|
PHYSAC_PENETRATION_CORRECTION: float = 0.4
|
||||||
PHYSAC_PI: float = 3.141592653589793
|
|
||||||
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
|
|
||||||
PHYSAC_FLT_MAX: float = 3.402823466e+38
|
PHYSAC_FLT_MAX: float = 3.402823466e+38
|
||||||
PHYSAC_EPSILON: float = 1e-06
|
PHYSAC_EPSILON: float = 1e-06
|
||||||
GLFW_VERSION_MAJOR: int = 3
|
GLFW_VERSION_MAJOR: int = 3
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
*
|
*
|
||||||
* DESCRIPTION:
|
* DESCRIPTION:
|
||||||
*
|
*
|
||||||
* Physac is a small 2D physics engine written in pure C. The engine uses a fixed time-step thread loop
|
* Physac is a small 2D physics library written in pure C. The engine uses a fixed time-step thread loop
|
||||||
* to simulate physics. A physics step contains the following phases: get collision information,
|
* to simluate physics. A physics step contains the following phases: get collision information,
|
||||||
* apply dynamics, collision solving and position correction. It uses a very simple struct for physic
|
* apply dynamics, collision solving and position correction. It uses a very simple struct for physic
|
||||||
* bodies with a position vector to be used in any 3D rendering API.
|
* bodies with a position vector to be used in any 3D rendering API.
|
||||||
*
|
*
|
||||||
|
@ -16,41 +16,49 @@
|
||||||
* If not defined, the library is in header only mode and can be included in other headers
|
* If not defined, the library is in header only mode and can be included in other headers
|
||||||
* or source files without problems. But only ONE file should hold the implementation.
|
* or source files without problems. But only ONE file should hold the implementation.
|
||||||
*
|
*
|
||||||
* #define PHYSAC_DEBUG
|
* #define PHYSAC_STATIC (defined by default)
|
||||||
* Show debug traces log messages about physic bodies creation/destruction, physic system errors,
|
* The generated implementation will stay private inside implementation file and all
|
||||||
* some calculations results and NULL reference exceptions.
|
* internal symbols and functions will only be visible inside that file.
|
||||||
*
|
*
|
||||||
* #define PHYSAC_AVOID_TIMMING_SYSTEM
|
* #define PHYSAC_NO_THREADS
|
||||||
* Disables internal timming system, used by UpdatePhysics() to launch timmed physic steps,
|
* The generated implementation won't include pthread library and user must create a secondary thread to call PhysicsThread().
|
||||||
* it allows just running UpdatePhysics() automatically on a separate thread at a desired time step.
|
* It is so important that the thread where PhysicsThread() is called must not have v-sync or any other CPU limitation.
|
||||||
* In case physics steps update needs to be controlled by user with a custom timming mechanism,
|
*
|
||||||
* just define this flag and the internal timming mechanism will be avoided, in that case,
|
* #define PHYSAC_STANDALONE
|
||||||
* timming libraries are neither required by the module.
|
* Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
|
||||||
|
* internally in the library and input management and drawing functions must be provided by
|
||||||
|
* the user (check library implementation for further details).
|
||||||
|
*
|
||||||
|
* #define PHYSAC_DEBUG
|
||||||
|
* Traces log messages when creating and destroying physics bodies and detects errors in physics
|
||||||
|
* calculations and reference exceptions; it is useful for debug purposes
|
||||||
*
|
*
|
||||||
* #define PHYSAC_MALLOC()
|
* #define PHYSAC_MALLOC()
|
||||||
* #define PHYSAC_CALLOC()
|
|
||||||
* #define PHYSAC_FREE()
|
* #define PHYSAC_FREE()
|
||||||
* You can define your own malloc/free implementation replacing stdlib.h malloc()/free() functions.
|
* You can define your own malloc/free implementation replacing stdlib.h malloc()/free() functions.
|
||||||
* Otherwise it will include stdlib.h and use the C standard library malloc()/free() function.
|
* Otherwise it will include stdlib.h and use the C standard library malloc()/free() function.
|
||||||
*
|
*
|
||||||
* COMPILATION:
|
|
||||||
*
|
*
|
||||||
* Use the following code to compile with GCC:
|
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static -lraylib -lopengl32 -lgdi32 -lwinmm -std=c99
|
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
|
||||||
*
|
*
|
||||||
* VERSIONS HISTORY:
|
* Use the following code to compile:
|
||||||
* 1.1 (20-Jan-2021) @raysan5: Library general revision
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static -lraylib -lpthread -lopengl32 -lgdi32 -lwinmm -std=c99
|
||||||
* Removed threading system (up to the user)
|
*
|
||||||
* Support MSVC C++ compilation using CLITERAL()
|
* VERY THANKS TO:
|
||||||
* Review DEBUG mechanism for TRACELOG() and all TRACELOG() messages
|
* - raysan5: helped with library design
|
||||||
* Review internal variables/functions naming for consistency
|
* - ficoos: added support for Linux
|
||||||
* Allow option to avoid internal timming system, to allow app manage the steps
|
* - R8D8: added support for Linux
|
||||||
* 1.0 (12-Jun-2017) First release of the library
|
* - jubalh: fixed implementation of time calculations
|
||||||
|
* - a3f: fixed implementation of time calculations
|
||||||
|
* - define-private-public: added support for OSX
|
||||||
|
* - pamarcos: fixed implementation of physics steps
|
||||||
|
* - noshbar: fixed some memory leaks
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016-2022 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5)
|
* Copyright (c) 2016-2025 Victor Fisac (github: @victorfisac)
|
||||||
*
|
*
|
||||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
* will the authors be held liable for any damages arising from the use of this software.
|
* will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
@ -68,39 +76,41 @@
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
// Function specifiers in case library is build/used as a shared library (Windows)
|
// #define PHYSAC_STATIC
|
||||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
// #define PHYSAC_NO_THREADS
|
||||||
// Allow custom memory allocators
|
// #define PHYSAC_STANDALONE
|
||||||
|
// #define PHYSAC_DEBUG
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Data Types Structure Definition
|
// Types and Structures Definition
|
||||||
|
// NOTE: Below types are required for PHYSAC_STANDALONE usage
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
typedef enum PhysicsShapeType { PHYSICS_CIRCLE = 0, PHYSICS_POLYGON } PhysicsShapeType;
|
typedef enum PhysicsShapeType { PHYSICS_CIRCLE, PHYSICS_POLYGON } PhysicsShapeType;
|
||||||
// Previously defined to be used in PhysicsShape struct as circular dependencies
|
// Previously defined to be used in PhysicsShape struct as circular dependencies
|
||||||
typedef struct PhysicsBodyData *PhysicsBody;
|
typedef struct PhysicsBodyData *PhysicsBody;
|
||||||
// Matrix2x2 type (used for polygon shape rotation matrix)
|
// Mat2 type (used for polygon shape rotation matrix)
|
||||||
typedef struct Matrix2x2 {
|
typedef struct Mat2 {
|
||||||
float m00;
|
float m00;
|
||||||
float m01;
|
float m01;
|
||||||
float m10;
|
float m10;
|
||||||
float m11;
|
float m11;
|
||||||
} Matrix2x2;
|
} Mat2;
|
||||||
typedef struct PhysicsVertexData {
|
typedef struct PolygonData {
|
||||||
unsigned int vertexCount; // Vertex count (positions and normals)
|
unsigned int vertexCount; // Current used vertex and normals count
|
||||||
Vector2 positions[24 /* Maximum number of vertex for polygons shapes*/]; // Vertex positions vectors
|
Vector2 positions[24]; // Polygon vertex positions vectors
|
||||||
Vector2 normals[24 /* Maximum number of vertex for polygons shapes*/]; // Vertex normals vectors
|
Vector2 normals[24]; // Polygon vertex normals vectors
|
||||||
} PhysicsVertexData;
|
} PolygonData;
|
||||||
typedef struct PhysicsShape {
|
typedef struct PhysicsShape {
|
||||||
PhysicsShapeType type; // Shape type (circle or polygon)
|
PhysicsShapeType type; // Physics shape type (circle or polygon)
|
||||||
PhysicsBody body; // Shape physics body data pointer
|
PhysicsBody body; // Shape physics body reference
|
||||||
PhysicsVertexData vertexData; // Shape vertices data (used for polygon shapes)
|
float radius; // Circle shape radius (used for circle shapes)
|
||||||
float radius; // Shape radius (used for circle shapes)
|
Mat2 transform; // Vertices transform matrix 2x2
|
||||||
Matrix2x2 transform; // Vertices transform matrix 2x2
|
PolygonData vertexData; // Polygon shape vertices position and normals data (just used for polygon shapes)
|
||||||
} PhysicsShape;
|
} PhysicsShape;
|
||||||
typedef struct PhysicsBodyData {
|
typedef struct PhysicsBodyData {
|
||||||
unsigned int id; // Unique identifier
|
unsigned int id; // Reference unique identifier
|
||||||
bool enabled; // Enabled dynamics state (collisions are calculated anyway)
|
bool enabled; // Enabled dynamics state (collisions are calculated anyway)
|
||||||
Vector2 position; // Physics body shape pivot
|
Vector2 position; // Physics body shape pivot
|
||||||
Vector2 velocity; // Current linear velocity applied to position
|
Vector2 velocity; // Current linear velocity applied to position
|
||||||
|
@ -118,10 +128,10 @@ typedef struct PhysicsBodyData {
|
||||||
bool useGravity; // Apply gravity force to dynamics
|
bool useGravity; // Apply gravity force to dynamics
|
||||||
bool isGrounded; // Physics grounded on other body state
|
bool isGrounded; // Physics grounded on other body state
|
||||||
bool freezeOrient; // Physics rotation constraint
|
bool freezeOrient; // Physics rotation constraint
|
||||||
PhysicsShape shape; // Physics body shape information (type, radius, vertices, transform)
|
PhysicsShape shape; // Physics body shape information (type, radius, vertices, normals)
|
||||||
} PhysicsBodyData;
|
} PhysicsBodyData;
|
||||||
typedef struct PhysicsManifoldData {
|
typedef struct PhysicsManifoldData {
|
||||||
unsigned int id; // Unique identifier
|
unsigned int id; // Reference unique identifier
|
||||||
PhysicsBody bodyA; // Manifold first physics body reference
|
PhysicsBody bodyA; // Manifold first physics body reference
|
||||||
PhysicsBody bodyB; // Manifold second physics body reference
|
PhysicsBody bodyB; // Manifold second physics body reference
|
||||||
float penetration; // Depth of penetration from collision
|
float penetration; // Depth of penetration from collision
|
||||||
|
@ -135,29 +145,25 @@ typedef struct PhysicsManifoldData {
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Physics system management
|
extern /* Functions visible from other files*/ void InitPhysics(void); // Initializes physics values, pointers and creates physics loop thread
|
||||||
void InitPhysics(void); // Initializes physics system
|
extern /* Functions visible from other files*/ void RunPhysicsStep(void); // Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop
|
||||||
void UpdatePhysics(void); // Update physics system
|
extern /* Functions visible from other files*/ void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default
|
||||||
void ResetPhysics(void); // Reset physics system (global variables)
|
extern /* Functions visible from other files*/ bool IsPhysicsEnabled(void); // Returns true if physics thread is currently enabled
|
||||||
void ClosePhysics(void); // Close physics system and unload used memory
|
extern /* Functions visible from other files*/ void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
|
||||||
void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default
|
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
|
||||||
void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
|
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
|
||||||
// Physic body creation/destroy
|
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
|
||||||
PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
|
extern /* Functions visible from other files*/ void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body
|
||||||
PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
|
extern /* Functions visible from other files*/ void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body
|
||||||
PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
|
extern /* Functions visible from other files*/ void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
|
||||||
void DestroyPhysicsBody(PhysicsBody body); // Destroy a physics body
|
extern /* Functions visible from other files*/ int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies
|
||||||
// Physic body forces
|
extern /* Functions visible from other files*/ PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
|
||||||
void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body
|
extern /* Functions visible from other files*/ int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
|
||||||
void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body
|
extern /* Functions visible from other files*/ int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
|
||||||
void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
|
extern /* Functions visible from other files*/ Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)
|
||||||
void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter
|
extern /* Functions visible from other files*/ void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter
|
||||||
// Query physics info
|
extern /* Functions visible from other files*/ void DestroyPhysicsBody(PhysicsBody body); // Unitializes and destroy a physics body
|
||||||
PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
|
extern /* Functions visible from other files*/ void ClosePhysics(void); // Unitializes physics pointers and closes physics loop thread
|
||||||
int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies
|
|
||||||
int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
|
|
||||||
int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
|
|
||||||
Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)
|
|
||||||
/***********************************************************************************
|
/***********************************************************************************
|
||||||
*
|
*
|
||||||
* PHYSAC IMPLEMENTATION
|
* PHYSAC IMPLEMENTATION
|
||||||
|
|
Reference in a new issue