Added check for empty cylinder.
This commit is contained in:
parent
d92531b81d
commit
7ae690f918
|
|
@ -714,6 +714,10 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
|
||||||
if(sides < 3) sides = 3;
|
if(sides < 3) sides = 3;
|
||||||
|
|
||||||
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
||||||
|
if(direction.x == direction.x && direction.y == direction.y && direction.z == direction.z) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Construct a basis of the base and the top face:
|
// Construct a basis of the base and the top face:
|
||||||
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
|
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
|
||||||
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
|
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
|
||||||
|
|
@ -804,10 +808,14 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
|
||||||
int numVertex = sides*6;
|
int numVertex = sides*6;
|
||||||
rlCheckRenderBatchLimit(numVertex);
|
rlCheckRenderBatchLimit(numVertex);
|
||||||
|
|
||||||
Vector3 difference = Vector3Subtract(endPos, startPos);
|
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
||||||
|
if(direction.x == direction.x && direction.y == direction.y && direction.z == direction.z) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Construct a basis of the base and the top face:
|
// Construct a basis of the base and the top face:
|
||||||
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(difference));
|
Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
|
||||||
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, difference));
|
Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
|
||||||
|
|
||||||
float baseAngle = (2.0*PI)/sides;
|
float baseAngle = (2.0*PI)/sides;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user