diff options
| author | raysan5 <[email protected]> | 2020-12-24 23:07:52 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-12-24 23:07:52 +0100 |
| commit | ea0f6c7a26f3a61f3be542aa8f066ce033766a9f (patch) | |
| tree | 403dec84eb60bf77cd7fa89dde99b193bddfe89e /src | |
| parent | b93c4b0c2071dad67276806d00d47c8cf7b59f07 (diff) | |
| download | raylib-ea0f6c7a26f3a61f3be542aa8f066ce033766a9f.tar.gz raylib-ea0f6c7a26f3a61f3be542aa8f066ce033766a9f.zip | |
Replace TABS by 4 spaces
Diffstat (limited to 'src')
| -rw-r--r-- | src/models.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/models.c b/src/models.c index de29585a..2e72b64e 100644 --- a/src/models.c +++ b/src/models.c @@ -2871,44 +2871,44 @@ RayHitInfo GetCollisionRayMesh(Ray ray, Mesh mesh, Matrix transform) { RayHitInfo result = { 0 }; - // Check if mesh vertex data on CPU for testing - if (mesh.vertices != NULL) - { - // model->mesh.triangleCount may not be set, vertexCount is more reliable - int triangleCount = mesh.vertexCount / 3; - - // Test against all triangles in mesh - for (int i = 0; i < triangleCount; i++) - { - Vector3 a, b, c; - Vector3* vertdata = (Vector3*)mesh.vertices; - - if (mesh.indices) - { - a = vertdata[mesh.indices[i * 3 + 0]]; - b = vertdata[mesh.indices[i * 3 + 1]]; - c = vertdata[mesh.indices[i * 3 + 2]]; - } - else - { - a = vertdata[i * 3 + 0]; - b = vertdata[i * 3 + 1]; - c = vertdata[i * 3 + 2]; - } - - a = Vector3Transform(a, transform); - b = Vector3Transform(b, transform); - c = Vector3Transform(c, transform); - - RayHitInfo triHitInfo = GetCollisionRayTriangle(ray, a, b, c); - - if (triHitInfo.hit) - { - // Save the closest hit triangle - if ((!result.hit) || (result.distance > triHitInfo.distance)) result = triHitInfo; - } - } - } + // Check if mesh vertex data on CPU for testing + if (mesh.vertices != NULL) + { + // model->mesh.triangleCount may not be set, vertexCount is more reliable + int triangleCount = mesh.vertexCount / 3; + + // Test against all triangles in mesh + for (int i = 0; i < triangleCount; i++) + { + Vector3 a, b, c; + Vector3* vertdata = (Vector3*)mesh.vertices; + + if (mesh.indices) + { + a = vertdata[mesh.indices[i * 3 + 0]]; + b = vertdata[mesh.indices[i * 3 + 1]]; + c = vertdata[mesh.indices[i * 3 + 2]]; + } + else + { + a = vertdata[i * 3 + 0]; + b = vertdata[i * 3 + 1]; + c = vertdata[i * 3 + 2]; + } + + a = Vector3Transform(a, transform); + b = Vector3Transform(b, transform); + c = Vector3Transform(c, transform); + + RayHitInfo triHitInfo = GetCollisionRayTriangle(ray, a, b, c); + + if (triHitInfo.hit) + { + // Save the closest hit triangle + if ((!result.hit) || (result.distance > triHitInfo.distance)) result = triHitInfo; + } + } + } return result; } |
