Skip to content

Commit 0cec4eb

Browse files
committed
Standardizing function declarations
1 parent d3a0b54 commit 0cec4eb

File tree

14 files changed

+115
-37
lines changed

14 files changed

+115
-37
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [4.0.3] - Unreleased
8+
### Changed
9+
- CMake now used for raylib dependency, rather than git submodules
10+
- Standardized functions across:
11+
- Color
12+
- Material
13+
- Mesh
14+
- Model
15+
- ModelAnimation
16+
- Physics
17+
- Ray
18+
- Rectangle
19+
- Texture
20+
- Window
21+
722
## [4.0.2] - 2021-12-24
823
### Added
924
- `Image::IsLoaded()`

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.11)
22
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
33
project (raylib-cpp
4-
VERSION 4.0.2
4+
VERSION 4.0.3
55
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
66
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
77
LANGUAGES C CXX)

examples/physics/physics_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int main(void)
5555
// Update
5656
//----------------------------------------------------------------------------------
5757
// Delay initialization of variables due to physics reset async
58-
physics.UpdateStep();
58+
physics.Update();
5959

6060
if (needsReset)
6161
{

include/Color.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Color : public ::Color {
162162
}
163163

164164
inline Color& DrawText(
165-
const ::Font font,
165+
const ::Font& font,
166166
const std::string& text,
167167
::Vector2 position,
168168
::Vector2 origin,

include/Material.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ class Material : public ::Material {
9191
return *this;
9292
}
9393

94+
/**
95+
* Draw a 3d mesh with material and transform
96+
*/
97+
inline const Material& DrawMesh(const ::Mesh& mesh, ::Matrix transform) const {
98+
::DrawMesh(mesh, *this, transform);
99+
return *this;
100+
}
101+
102+
/**
103+
* Draw multiple mesh instances with material and different transforms
104+
*/
105+
inline const Material& DrawMesh(const ::Mesh& mesh, ::Matrix* transforms, int instances) const {
106+
::DrawMeshInstanced(mesh, *this, transforms, instances);
107+
return *this;
108+
}
109+
94110
private:
95111
inline void set(const ::Material& material) {
96112
shader = material.shader;

include/Mesh.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,17 @@ class Mesh : public ::Mesh {
206206
::UpdateMeshBuffer(*this, index, data, dataSize, offset);
207207
}
208208

209+
/**
210+
* Draw a 3d mesh with material and transform
211+
*/
209212
inline void Draw(const ::Material& material, const ::Matrix& transform) {
210213
::DrawMesh(*this, material, transform);
211214
}
212215

213-
inline void DrawInstanced(const ::Material& material, ::Matrix* transforms, int instances) {
216+
/**
217+
* Draw multiple mesh instances with material and different transforms
218+
*/
219+
inline void Draw(const ::Material& material, ::Matrix* transforms, int instances) {
214220
::DrawMeshInstanced(*this, material, transforms, instances);
215221
}
216222

@@ -249,15 +255,15 @@ class Mesh : public ::Mesh {
249255
/**
250256
* Compute mesh tangents
251257
*/
252-
inline Mesh& Tangents() {
258+
inline Mesh& GenTangents() {
253259
::GenMeshTangents(this);
254260
return *this;
255261
}
256262

257263
/**
258264
* Compute mesh binormals (aka bitangent)
259265
*/
260-
inline Mesh& Binormals() {
266+
inline Mesh& GenBinormals() {
261267
::GenMeshBinormals(this);
262268
return *this;
263269
}

include/Model.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,20 @@ class Model : public ::Model {
174174
return *this;
175175
}
176176

177+
/**
178+
* Compute model bounding box limits (considers all meshes)
179+
*/
180+
inline BoundingBox GetBoundingBox() const {
181+
return ::GetModelBoundingBox(*this);
182+
}
183+
184+
/**
185+
* Compute model bounding box limits (considers all meshes)
186+
*/
187+
operator BoundingBox() const {
188+
return ::GetModelBoundingBox(*this);
189+
}
190+
177191
private:
178192
inline void set(const ::Model& model) {
179193
transform = model.transform;

include/ModelAnimation.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class ModelAnimation : public ::ModelAnimation {
5656
return *this;
5757
}
5858

59-
6059
ModelAnimation& operator=(const ModelAnimation&) = delete;
6160

6261
ModelAnimation& operator=(ModelAnimation&& other) {

include/Physics.hpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ class Physics {
3434
return *this;
3535
}
3636

37-
inline Physics& Close() {
38-
::ClosePhysics();
37+
inline Physics& Update() {
38+
::UpdatePhysics();
3939
return *this;
4040
}
4141

42-
inline Physics& UpdateStep() {
43-
::UpdatePhysicsStep();
42+
inline Physics& Reset() {
43+
::ResetPhysics();
44+
return *this;
45+
}
46+
47+
inline Physics& Close() {
48+
::ClosePhysics();
4449
return *this;
4550
}
4651

@@ -66,6 +71,11 @@ class Physics {
6671
return ::CreatePhysicsBodyPolygon(pos, radius, sides, density);
6772
}
6873

74+
inline Physics& DestroyBody(PhysicsBody body) {
75+
::DestroyPhysicsBody(body);
76+
return *this;
77+
}
78+
6979
inline Physics& AddForce(PhysicsBody body, Vector2 force) {
7080
::PhysicsAddForce(body, force);
7181
return *this;
@@ -81,6 +91,11 @@ class Physics {
8191
return *this;
8292
}
8393

94+
inline Physics& SetBodyRotation(PhysicsBody body, float radians) {
95+
::SetPhysicsBodyRotation(body, radians);
96+
return *this;
97+
}
98+
8499
inline int GetBodiesCount() const {
85100
return ::GetPhysicsBodiesCount();
86101
}
@@ -100,21 +115,6 @@ class Physics {
100115
inline Vector2 GetShapeVertex(PhysicsBody body, int vertex) const {
101116
return ::GetPhysicsShapeVertex(body, vertex);
102117
}
103-
104-
inline Physics& SetBodyRotation(PhysicsBody body, float radians) {
105-
::SetPhysicsBodyRotation(body, radians);
106-
return *this;
107-
}
108-
109-
inline Physics& DestroyBody(PhysicsBody body) {
110-
::DestroyPhysicsBody(body);
111-
return *this;
112-
}
113-
114-
inline Physics& Reset() {
115-
::ResetPhysics();
116-
return *this;
117-
}
118118
};
119119
} // namespace raylib
120120

include/Ray.hpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Ray : public ::Ray {
4747
/**
4848
* Get collision information between ray and sphere
4949
*/
50-
inline RayCollision GetCollisionSphere(::Vector3 center, float radius) const {
50+
inline RayCollision GetCollision(::Vector3 center, float radius) const {
5151
return GetRayCollisionSphere(*this, center, radius);
5252
}
5353

@@ -59,26 +59,33 @@ class Ray : public ::Ray {
5959
}
6060

6161
/**
62-
* Get collision information between ray and box
62+
* Get collision info between ray and model
6363
*/
64-
inline RayCollision GetCollision(const ::BoundingBox& box) const {
65-
return GetRayCollisionBox(*this, box);
64+
inline RayCollision GetCollision(const ::Model& model) const {
65+
return GetRayCollisionModel(*this, model);
6666
}
6767

6868
/**
69-
* Get collision info between ray and model
69+
* Get collision information between ray and mesh
7070
*/
71-
inline RayCollision GetCollision(const ::Model& model) const {
72-
return GetRayCollisionModel(*this, model);
71+
inline RayCollision GetCollision(const ::Mesh& mesh, const ::Matrix& transform) const {
72+
return GetRayCollisionMesh(*this, mesh, transform);
7373
}
7474

7575
/**
7676
* Get collision info between ray and triangle
7777
*/
78-
inline RayCollision GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const {
78+
inline RayCollision GetCollision(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const {
7979
return GetRayCollisionTriangle(*this, p1, p2, p3);
8080
}
8181

82+
/**
83+
* Get collision info between ray and quad
84+
*/
85+
inline RayCollision GetCollision(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4) const {
86+
return GetRayCollisionQuad(*this, p1, p2, p3, p4);
87+
}
88+
8289
private:
8390
inline void set(const ::Ray& ray) {
8491
position = ray.position;

0 commit comments

Comments
 (0)