Skip to content

Commit

Permalink
Added missing error checks on mesh shape creation
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardodoria committed Oct 28, 2023
1 parent b6d31b0 commit eea0d00
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions engine/core/subsystem/PhysicsSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,17 +535,19 @@ void PhysicsSystem::createMeshShape3D(Entity entity, MeshComponent& mesh){

if (jindices.size() == 0){
Log::error("Cannot create mesh shape without indices for 3D Body: %u", entity);
}
}else if (jvertices.size() == 0){
Log::error("Cannot create mesh shape without vertices for 3D Body: %u", entity);
}else{
JPH::MeshShapeSettings shape_settings(jvertices, jindices);

JPH::MeshShapeSettings shape_settings(jvertices, jindices);
JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
if (shape_result.IsValid()){
JPH::ShapeRefC shape = shape_result.Get();

JPH::ShapeSettings::ShapeResult shape_result = shape_settings.Create();
if (shape_result.IsValid()){
JPH::ShapeRefC shape = shape_result.Get();

createGenericJoltBody(entity, *body, shape.GetPtr());
}else{
Log::error("Cannot create shape for 3D Body: %u", entity);
createGenericJoltBody(entity, *body, shape.GetPtr());
}else{
Log::error("Cannot create shape for 3D Body: %u", entity);
}
}
}
}
Expand Down

0 comments on commit eea0d00

Please sign in to comment.