Matrix variables renaming
This commit is contained in:
parent
70d405b41b
commit
891c4a458a
2 changed files with 16 additions and 16 deletions
12
src/core.c
12
src/core.c
|
@ -774,8 +774,8 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
|
||||||
{
|
{
|
||||||
Ray ray;
|
Ray ray;
|
||||||
|
|
||||||
Matrix proj = MatrixIdentity();
|
Matrix matProj = MatrixIdentity();
|
||||||
Matrix view = MatrixLookAt(camera.position, camera.target, camera.up);
|
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||||
|
|
||||||
// Calculate projection matrix for the camera
|
// Calculate projection matrix for the camera
|
||||||
float aspect = (float)GetScreenWidth()/(float)GetScreenHeight();
|
float aspect = (float)GetScreenWidth()/(float)GetScreenHeight();
|
||||||
|
@ -783,8 +783,8 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
|
||||||
double right = top*aspect;
|
double right = top*aspect;
|
||||||
|
|
||||||
// NOTE: zNear and zFar values are important for depth
|
// NOTE: zNear and zFar values are important for depth
|
||||||
proj = MatrixFrustum(-right, right, -top, top, 0.01f, 1000.0f);
|
matProj = MatrixFrustum(-right, right, -top, top, 0.01f, 1000.0f);
|
||||||
MatrixTranspose(&proj);
|
MatrixTranspose(&matProj);
|
||||||
|
|
||||||
// NOTE: Our screen origin is top-left instead of bottom-left: transform required!
|
// NOTE: Our screen origin is top-left instead of bottom-left: transform required!
|
||||||
float invertedMouseY = (float)GetScreenHeight() - mousePosition.y;
|
float invertedMouseY = (float)GetScreenHeight() - mousePosition.y;
|
||||||
|
@ -797,8 +797,8 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
|
||||||
Vector3 nearPoint = { mousePosition.x, invertedMouseY, 0.0f };
|
Vector3 nearPoint = { mousePosition.x, invertedMouseY, 0.0f };
|
||||||
Vector3 farPoint = { mousePosition.x, invertedMouseY, 1.0f };
|
Vector3 farPoint = { mousePosition.x, invertedMouseY, 1.0f };
|
||||||
|
|
||||||
nearPoint = rlglUnproject(nearPoint, proj, view);
|
nearPoint = rlglUnproject(nearPoint, matProj, matView);
|
||||||
farPoint = rlglUnproject(farPoint, proj, view); // TODO: it seems it doesn't work...
|
farPoint = rlglUnproject(farPoint, matProj, matView); // TODO: it seems it doesn't work...
|
||||||
|
|
||||||
Vector3 direction = VectorSubtract(farPoint, nearPoint);
|
Vector3 direction = VectorSubtract(farPoint, nearPoint);
|
||||||
VectorNormalize(&direction);
|
VectorNormalize(&direction);
|
||||||
|
|
20
src/rlgl.c
20
src/rlgl.c
|
@ -397,33 +397,33 @@ void rlLoadIdentity(void)
|
||||||
// Multiply the current matrix by a translation matrix
|
// Multiply the current matrix by a translation matrix
|
||||||
void rlTranslatef(float x, float y, float z)
|
void rlTranslatef(float x, float y, float z)
|
||||||
{
|
{
|
||||||
Matrix mat = MatrixTranslate(x, y, z);
|
Matrix matTranslation = MatrixTranslate(x, y, z);
|
||||||
MatrixTranspose(&mat);
|
MatrixTranspose(&matTranslation);
|
||||||
|
|
||||||
*currentMatrix = MatrixMultiply(*currentMatrix, mat);
|
*currentMatrix = MatrixMultiply(*currentMatrix, matTranslation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply the current matrix by a rotation matrix
|
// Multiply the current matrix by a rotation matrix
|
||||||
void rlRotatef(float angleDeg, float x, float y, float z)
|
void rlRotatef(float angleDeg, float x, float y, float z)
|
||||||
{
|
{
|
||||||
Matrix rotation = MatrixIdentity();
|
Matrix matRotation = MatrixIdentity();
|
||||||
|
|
||||||
Vector3 axis = (Vector3){ x, y, z };
|
Vector3 axis = (Vector3){ x, y, z };
|
||||||
VectorNormalize(&axis);
|
VectorNormalize(&axis);
|
||||||
rotation = MatrixRotate(angleDeg*DEG2RAD, axis);
|
matRotation = MatrixRotate(angleDeg*DEG2RAD, axis);
|
||||||
|
|
||||||
MatrixTranspose(&rotation);
|
MatrixTranspose(&matRotation);
|
||||||
|
|
||||||
*currentMatrix = MatrixMultiply(*currentMatrix, rotation);
|
*currentMatrix = MatrixMultiply(*currentMatrix, matRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply the current matrix by a scaling matrix
|
// Multiply the current matrix by a scaling matrix
|
||||||
void rlScalef(float x, float y, float z)
|
void rlScalef(float x, float y, float z)
|
||||||
{
|
{
|
||||||
Matrix mat = MatrixScale(x, y, z);
|
Matrix matScale = MatrixScale(x, y, z);
|
||||||
MatrixTranspose(&mat);
|
MatrixTranspose(&matScale);
|
||||||
|
|
||||||
*currentMatrix = MatrixMultiply(*currentMatrix, mat);
|
*currentMatrix = MatrixMultiply(*currentMatrix, matScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply the current matrix by another matrix
|
// Multiply the current matrix by another matrix
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue