Skip to content

Conversation

@themushroompirates
Copy link
Contributor

No description provided.

Comment on lines +276 to +341
switch ( total ) {
case 0: {
// the entire face lies inside of the plane, no clipping needed
AddTriangleToMeshBuilder(outMesh, (Vector3[3]){inMesh->vertices[i], inMesh->vertices[i+1], inMesh->vertices[i+2]});
break;
}

case 1: {
// one vertex lies outside of the plane, perform clipping

if (v1Out) {
nV1 = inMesh->vertices[ i + 1 ];
nV2 = inMesh->vertices[ i + 2 ];
nV3 = ClipSegment( inMesh->vertices[ i ], nV1, planes[face], s );
nV4 = ClipSegment( inMesh->vertices[ i ], nV2, planes[face], s );
}

if (v2Out) {
nV1 = inMesh->vertices[ i ];
nV2 = inMesh->vertices[ i + 2 ];
nV3 = ClipSegment( inMesh->vertices[ i + 1 ], nV1, planes[face], s );
nV4 = ClipSegment( inMesh->vertices[ i + 1 ], nV2, planes[face], s );

AddTriangleToMeshBuilder(outMesh, (Vector3[3]){nV3, nV2, nV1});
AddTriangleToMeshBuilder(outMesh, (Vector3[3]){nV2, nV3, nV4});
break;
}

if (v3Out) {
nV1 = inMesh->vertices[ i ];
nV2 = inMesh->vertices[ i + 1 ];
nV3 = ClipSegment( inMesh->vertices[ i + 2 ], nV1, planes[face], s );
nV4 = ClipSegment( inMesh->vertices[ i + 2 ], nV2, planes[face], s );
}

AddTriangleToMeshBuilder(outMesh, (Vector3[3]){nV1, nV2, nV3});
AddTriangleToMeshBuilder(outMesh, (Vector3[3]){nV4, nV3, nV2});

break;
}

case 2: {
// two vertices lies outside of the plane, perform clipping
if (!v1Out) {
nV1 = inMesh->vertices[ i ];
nV2 = ClipSegment( nV1, inMesh->vertices[ i + 1 ], planes[face], s );
nV3 = ClipSegment( nV1, inMesh->vertices[ i + 2 ], planes[face], s );
AddTriangleToMeshBuilder(outMesh, (Vector3[3]){nV1, nV2, nV3});
}
if (!v2Out) {
nV1 = inMesh->vertices[ i + 1 ];
nV2 = ClipSegment( nV1, inMesh->vertices[ i + 2 ], planes[face], s );
nV3 = ClipSegment( nV1, inMesh->vertices[ i ], planes[face], s );
AddTriangleToMeshBuilder(outMesh, (Vector3[3]){nV1, nV2, nV3});
}
if (!v3Out) {
nV1 = inMesh->vertices[ i + 2 ];
nV2 = ClipSegment( nV1, inMesh->vertices[ i ], planes[face], s );
nV3 = ClipSegment( nV1, inMesh->vertices[ i + 1 ], planes[face], s );
AddTriangleToMeshBuilder(outMesh, (Vector3[3]){nV1, nV2, nV3});
}
break;
}

case 3: {
// the entire face lies outside of the plane, so let's discard the corresponding vertices
break;
}

}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
1 (33 lines)
.
@raysan5
Copy link
Owner

raysan5 commented Oct 24, 2025

@themushroompirates Thanks! Great addition! Please, could you review the issues noted by CodeQL and also the raylib code conventions? Thanks!

@themushroompirates
Copy link
Contributor Author

@themushroompirates Thanks! Great addition! Please, could you review the issues noted by CodeQL and also the raylib code conventions? Thanks!

I've changed the code to follow the conventions, and reviewed the CodeQL issues - most of them were fine (and helpful - it was old code I had missed when cleaning), but the "switch case too long one", I think is a mistake. I could compress the code and make it unreadable, or tuck it away into functions or macros and make it harder to follow. It's just the size it needs to be.

@raysan5
Copy link
Owner

raysan5 commented Oct 25, 2025

@themushroompirates thanks for the review. What is the license or source for model and texture?

@themushroompirates
Copy link
Contributor Author

@themushroompirates thanks for the review. What is the license or source for model and texture?

It's CC-0, from kenney.nl

@raysan5 raysan5 merged commit dbcc508 into raysan5:master Oct 25, 2025
17 checks passed
@raysan5
Copy link
Owner

raysan5 commented Oct 25, 2025

@themushroompirates Thanks! Great addition! Merged! 😄

@themushroompirates themushroompirates deleted the example_models_decals branch October 26, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants