mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-10 11:56:27 +00:00
fixs issue mem leak with LoadModel / OBJ and issue with -1 material index (#969)
This commit is contained in:
@@ -669,7 +669,9 @@ Model LoadModel(const char *fileName)
|
|||||||
model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material));
|
model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material));
|
||||||
model.materials[0] = LoadMaterialDefault();
|
model.materials[0] = LoadMaterialDefault();
|
||||||
|
|
||||||
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
|
if (model.meshMaterial==NULL) {
|
||||||
|
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
@@ -2860,6 +2862,11 @@ static Model LoadOBJ(const char *fileName)
|
|||||||
|
|
||||||
// Assign mesh material for current mesh
|
// Assign mesh material for current mesh
|
||||||
model.meshMaterial[m] = attrib.material_ids[m];
|
model.meshMaterial[m] = attrib.material_ids[m];
|
||||||
|
|
||||||
|
// set unfound materials to default
|
||||||
|
if (model.meshMaterial[m] == -1) {
|
||||||
|
model.meshMaterial[m] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init model materials
|
// Init model materials
|
||||||
|
Reference in New Issue
Block a user