summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorchriscamacho <[email protected]>2019-08-08 08:57:21 +0100
committerRay <[email protected]>2019-08-08 09:57:21 +0200
commit2d5cc5ddbf3c0d157b67e7896f6b6efe58c65ef4 (patch)
tree37dc40212260b6f4d3f47b18c532a545aef50e79 /src
parentf3555a1016ec67105d67959a55b0fd9fda29fd25 (diff)
downloadraylib-2d5cc5ddbf3c0d157b67e7896f6b6efe58c65ef4.tar.gz
raylib-2d5cc5ddbf3c0d157b67e7896f6b6efe58c65ef4.zip
fixed xmloader bug, user must free model shaders and textures as they might be shared (#933)
Diffstat (limited to 'src')
-rw-r--r--src/models.c21
-rw-r--r--src/raudio.c2
2 files changed, 14 insertions, 9 deletions
diff --git a/src/models.c b/src/models.c
index e30eb547..df123fa7 100644
--- a/src/models.c
+++ b/src/models.c
@@ -71,7 +71,7 @@
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
-#define MAX_MESH_VBO 7 // Maximum number of vbo per mesh
+#define MAX_MESH_VBO 7 // Maximum number of vbo per mesh
//----------------------------------------------------------------------------------
// Types and Structures Definition
@@ -703,7 +703,12 @@ Model LoadModelFromMesh(Mesh mesh)
void UnloadModel(Model model)
{
for (int i = 0; i < model.meshCount; i++) UnloadMesh(model.meshes[i]);
- for (int i = 0; i < model.materialCount; i++) UnloadMaterial(model.materials[i]);
+
+ // as the user could be sharing shaders and textures between
+ // models, don't unload the material but free it's maps instead
+ // the user is responsible for freeing models shaders and textures
+ //for (int i = 0; i < model.materialCount; i++) UnloadMaterial(model.materials[i]);
+ for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps);
RL_FREE(model.meshes);
RL_FREE(model.materials);
@@ -2492,11 +2497,11 @@ bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, floa
// Simple way to check for collision, just checking distance between two points
// Unfortunately, sqrtf() is a costly operation, so we avoid it with following solution
/*
- float dx = centerA.x - centerB.x; // X distance between centers
- float dy = centerA.y - centerB.y; // Y distance between centers
- float dz = centerA.z - centerB.z; // Z distance between centers
+ float dx = centerA.x - centerB.x; // X distance between centers
+ float dy = centerA.y - centerB.y; // Y distance between centers
+ float dz = centerA.z - centerB.z; // Z distance between centers
- float distance = sqrtf(dx*dx + dy*dy + dz*dz); // Distance between centers
+ float distance = sqrtf(dx*dx + dy*dy + dz*dz); // Distance between centers
if (distance <= (radiusA + radiusB)) collision = true;
*/
@@ -3346,7 +3351,7 @@ static Model LoadGLTF(const char *fileName)
- Triangle-only meshes
- Not supported node hierarchies or transforms
- Only loads the diffuse texture... but not too hard to support other maps (normal, roughness/metalness...)
- - Only supports unsigned short indices (no byte/unsigned int)
+ - Only supports unsigned short indices (no byte/unsigned int)
- Only supports float for texture coordinates (no byte/unsigned short)
*************************************************************************************/
@@ -3435,7 +3440,7 @@ static Model LoadGLTF(const char *fileName)
if (img->uri)
{
- if ((strlen(img->uri) > 5) &&
+ if ((strlen(img->uri) > 5) &&
(img->uri[0] == 'd') &&
(img->uri[1] == 'a') &&
(img->uri[2] == 't') &&
diff --git a/src/raudio.c b/src/raudio.c
index bfd7ef22..40c13667 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -1250,7 +1250,7 @@ Music LoadMusicStream(const char *fileName)
int result = jar_xm_create_context_from_file(&ctxXm, 48000, fileName);
- if (result > 0) // XM context created successfully
+ if (result == 0) // XM context created successfully
{
music.ctxType = MUSIC_MODULE_XM;
jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops