Procházet zdrojové kódy

Fix issue with empty cylinder (#2050)

* Add DrawCylinderEx and DrawCylinderWiresEx

* Modify examples/models/models_geometric_shapes.c to show the
usage of DrawCylinder(Wires)Ex

* Simplified DrawCylinder and DrawCylinderWires to use the -Ex versions.

* This reverts commits f49b2598dd and
4542b32e4e.

* Fixed formatting.
Renamed base_angle to baseAngle.
Remove most of the raymath.h calls.

* Added check for empty cylinder.

* Added check for empty cylinder.

* Fix bug.

Co-authored-by: Horrowind <you@example.com>
pull/2063/head
Horrowind před 4 roky
odevzdal GitHub
rodič
revize
e545286369
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: 4AEE18F83AFDEB23
1 změnil soubory, kde provedl 11 přidání a 3 odebrání
  1. +11
    -3
      src/rmodels.c

+ 11
- 3
src/rmodels.c Zobrazit soubor

@ -714,6 +714,10 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
if(sides < 3) sides = 3;
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
if(direction.x == 0 && direction.y == 0 && direction.z == 0) {
return;
}
// Construct a basis of the base and the top face:
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
@ -804,10 +808,14 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
int numVertex = sides*6;
rlCheckRenderBatchLimit(numVertex);
Vector3 difference = Vector3Subtract(endPos, startPos);
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
if(direction.x == 0 && direction.y == 0 && direction.z == 0) {
return;
}
// Construct a basis of the base and the top face:
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(difference));
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, difference));
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
float baseAngle = (2.0*PI)/sides;

Načítá se…
Zrušit
Uložit