Remove tabs

This commit is contained in:
Ray 2021-06-08 21:01:17 +02:00
parent 9681a072d0
commit 76a907bb79

View file

@ -2815,7 +2815,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
{ {
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width // NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width }; Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width };
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
Vector3 right = { matView.m0, matView.m4, matView.m8 }; Vector3 right = { matView.m0, matView.m4, matView.m8 };
@ -2824,9 +2824,9 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
// NOTE: Billboard locked on axis-Y // NOTE: Billboard locked on axis-Y
Vector3 up = { 0.0f, 1.0f, 0.0f }; Vector3 up = { 0.0f, 1.0f, 0.0f };
Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2); Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2);
Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2); Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2);
Vector3 p1 = Vector3Add(rightScaled, upScaled); Vector3 p1 = Vector3Add(rightScaled, upScaled);
Vector3 p2 = Vector3Subtract(rightScaled, upScaled); Vector3 p2 = Vector3Subtract(rightScaled, upScaled);
@ -2834,50 +2834,50 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
Vector3 topRight = p1; Vector3 topRight = p1;
Vector3 bottomRight = p2; Vector3 bottomRight = p2;
Vector3 bottomLeft = Vector3Scale(p1, -1); Vector3 bottomLeft = Vector3Scale(p1, -1);
if (rotation != 0.0f) if (rotation != 0.0f)
{ {
float sinRotation = sinf(rotation*DEG2RAD); float sinRotation = sinf(rotation*DEG2RAD);
float cosRotation = cosf(rotation*DEG2RAD); float cosRotation = cosf(rotation*DEG2RAD);
// NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture // NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture
float rotateAboutX = sizeRatio.x*origin.x/2; float rotateAboutX = sizeRatio.x*origin.x/2;
float rotateAboutY = sizeRatio.y*origin.y/2; float rotateAboutY = sizeRatio.y*origin.y/2;
float xtvalue, ytvalue; float xtvalue, ytvalue;
float rotatedX, rotatedY; float rotatedX, rotatedY;
xtvalue = Vector3DotProduct(right, topLeft) - rotateAboutX; // Project points to x and y coordinates on the billboard plane xtvalue = Vector3DotProduct(right, topLeft) - rotateAboutX; // Project points to x and y coordinates on the billboard plane
ytvalue = Vector3DotProduct(up, topLeft) - rotateAboutY; ytvalue = Vector3DotProduct(up, topLeft) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
topLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); // Translate back to cartesian coordinates topLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); // Translate back to cartesian coordinates
xtvalue = Vector3DotProduct(right, topRight) - rotateAboutX; xtvalue = Vector3DotProduct(right, topRight) - rotateAboutX;
ytvalue = Vector3DotProduct(up, topRight) - rotateAboutY; ytvalue = Vector3DotProduct(up, topRight) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
topRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); topRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
xtvalue = Vector3DotProduct(right, bottomRight) - rotateAboutX; xtvalue = Vector3DotProduct(right, bottomRight) - rotateAboutX;
ytvalue = Vector3DotProduct(up, bottomRight) - rotateAboutY; ytvalue = Vector3DotProduct(up, bottomRight) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); bottomRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
xtvalue = Vector3DotProduct(right, bottomLeft)-rotateAboutX; xtvalue = Vector3DotProduct(right, bottomLeft)-rotateAboutX;
ytvalue = Vector3DotProduct(up, bottomLeft)-rotateAboutY; ytvalue = Vector3DotProduct(up, bottomLeft)-rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); bottomLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
} }
// Translate points to the draw center (position) // Translate points to the draw center (position)
topLeft = Vector3Add(topLeft, position); topLeft = Vector3Add(topLeft, position);
topRight = Vector3Add(topRight, position); topRight = Vector3Add(topRight, position);
bottomRight = Vector3Add(bottomRight, position); bottomRight = Vector3Add(bottomRight, position);
bottomLeft = Vector3Add(bottomLeft, position); bottomLeft = Vector3Add(bottomLeft, position);
rlCheckRenderBatchLimit(4); rlCheckRenderBatchLimit(4);
rlSetTexture(texture.id); rlSetTexture(texture.id);
@ -2902,7 +2902,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
rlVertex3f(topRight.x, topRight.y, topRight.z); rlVertex3f(topRight.x, topRight.y, topRight.z);
rlEnd(); rlEnd();
rlSetTexture(0); rlSetTexture(0);
} }
// Draw a bounding box with wires // Draw a bounding box with wires