"Improved" Dolphin matricies slightly

This commit is contained in:
2026-04-18 00:32:50 -05:00
parent 2451d73a7c
commit bddc9af3b6
3 changed files with 32 additions and 29 deletions
+17 -17
View File
@@ -130,24 +130,24 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
entityCameraSetZFar(cam, camCam, 100.0f); entityCameraSetZFar(cam, camCam, 100.0f);
// Floor // Floor
// entityid_t floorEnt = entityManagerAdd(); entityid_t floorEnt = entityManagerAdd();
// componentid_t floorPos = entityAddComponent(floorEnt, COMPONENT_TYPE_POSITION); componentid_t floorPos = entityAddComponent(floorEnt, COMPONENT_TYPE_POSITION);
// componentid_t floorMesh = entityAddComponent(floorEnt, COMPONENT_TYPE_MESH); componentid_t floorMesh = entityAddComponent(floorEnt, COMPONENT_TYPE_MESH);
// componentid_t floorMat = entityAddComponent(floorEnt, COMPONENT_TYPE_MATERIAL); componentid_t floorMat = entityAddComponent(floorEnt, COMPONENT_TYPE_MATERIAL);
// componentid_t floorPhys = entityAddComponent(floorEnt, COMPONENT_TYPE_PHYSICS); componentid_t floorPhys = entityAddComponent(floorEnt, COMPONENT_TYPE_PHYSICS);
// entityPositionSetPosition(floorEnt, floorPos, (vec3){ -5.0f, 0.0f, -5.0f }); entityPositionSetPosition(floorEnt, floorPos, (vec3){ -5.0f, 0.0f, -5.0f });
// entityPositionSetScale(floorEnt, floorPos, (vec3){ 10.0f, 1.0f, 10.0f }); entityPositionSetScale(floorEnt, floorPos, (vec3){ 10.0f, 1.0f, 10.0f });
// entityMeshSetMesh(floorEnt, floorMesh, &PLANE_MESH_SIMPLE); entityMeshSetMesh(floorEnt, floorMesh, &PLANE_MESH_SIMPLE);
// entityMaterialGetShaderMaterial(floorEnt, floorMat)->unlit.color = COLOR_GREEN; entityMaterialGetShaderMaterial(floorEnt, floorMat)->unlit.color = COLOR_GREEN;
// entityphysics_t *floorPhysData = entityPhysicsGet(floorEnt, floorPhys); entityphysics_t *floorPhysData = entityPhysicsGet(floorEnt, floorPhys);
// floorPhysData->type = PHYSICS_BODY_STATIC; floorPhysData->type = PHYSICS_BODY_STATIC;
// floorPhysData->shape.type = PHYSICS_SHAPE_PLANE; floorPhysData->shape.type = PHYSICS_SHAPE_PLANE;
// floorPhysData->shape.data.plane.normal[0] = 0.0f; floorPhysData->shape.data.plane.normal[0] = 0.0f;
// floorPhysData->shape.data.plane.normal[1] = 1.0f; floorPhysData->shape.data.plane.normal[1] = 1.0f;
// floorPhysData->shape.data.plane.normal[2] = 0.0f; floorPhysData->shape.data.plane.normal[2] = 0.0f;
// floorPhysData->shape.data.plane.distance = 0.0f; floorPhysData->shape.data.plane.distance = 0.0f;
// Box // Box
phBoxEnt = entityManagerAdd(); phBoxEnt = entityManagerAdd();
@@ -158,7 +158,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
entityMeshSetMesh(phBoxEnt, boxMesh, &CUBE_MESH_SIMPLE); entityMeshSetMesh(phBoxEnt, boxMesh, &CUBE_MESH_SIMPLE);
entityMaterialGetShaderMaterial(phBoxEnt, boxMat)->unlit.color = COLOR_RED; entityMaterialGetShaderMaterial(phBoxEnt, boxMat)->unlit.color = COLOR_RED;
entityPositionSetPosition(phBoxEnt, boxPos, (vec3){ 0.0f, 0.0f, 0.0f }); entityPositionSetPosition(phBoxEnt, boxPos, (vec3){ 0.0f, 1.0f, 0.0f });
/* Run the init script. */ /* Run the init script. */
scriptcontext_t ctx; scriptcontext_t ctx;
+11 -8
View File
@@ -228,13 +228,14 @@ errorret_t shaderUpdateMVPDolphin() {
// Set Model/View Matrix // Set Model/View Matrix
if(mvDirt) { if(mvDirt) {
// guMtxConcat( guMtxIdentity(SHADER_BOUND->matrixModel);
// SHADER_BOUND->matrixView, guMtxTransApply(SHADER_BOUND->matrixModel, SHADER_BOUND->matrixModel, 0.0F, 1.0F, 0.0F);
// SHADER_BOUND->matrixModel, guMtxConcat(
// SHADER_BOUND->matrixModelView SHADER_BOUND->matrixModel,
// ); SHADER_BOUND->matrixView,
// GX_LoadPosMtxImm(SHADER_BOUND->matrixModelView, GX_PNMTX0); SHADER_BOUND->matrixModelView
GX_LoadPosMtxImm(SHADER_BOUND->matrixView, GX_PNMTX0); );
GX_LoadPosMtxImm(SHADER_BOUND->matrixModelView, GX_PNMTX0);
} }
SHADER_BOUND->dirtyMatrix = 0; SHADER_BOUND->dirtyMatrix = 0;
@@ -256,7 +257,9 @@ void shaderMat4ToMtx(const mat4 inGlmMatrix, Mtx outGXMatrix) {
assertNotNull(inGlmMatrix, "Input matrix cannot be null"); assertNotNull(inGlmMatrix, "Input matrix cannot be null");
assertNotNull(outGXMatrix, "Output matrix cannot be null"); assertNotNull(outGXMatrix, "Output matrix cannot be null");
for(int row = 0; row < 4; ++row) {// Can perhaps be 3. guMtxIdentity(outGXMatrix);
for(int row = 0; row < 3; ++row) {
for(int col = 0; col < 4; ++col) { for(int col = 0; col < 4; ++col) {
outGXMatrix[row][col] = inGlmMatrix[col][row]; outGXMatrix[row][col] = inGlmMatrix[col][row];
} }
@@ -26,10 +26,10 @@ typedef struct shaderdolphin_s {
mat4 model; mat4 model;
bool_t isProjectionPerspective; bool_t isProjectionPerspective;
Mtx44 matrixProjection; alignas(32) Mtx44 matrixProjection;
Mtx matrixView; alignas(32) Mtx matrixView;
Mtx matrixModel; alignas(32) Mtx matrixModel;
Mtx matrixModelView; alignas(32) Mtx matrixModelView;
uint_fast8_t dirtyMatrix; uint_fast8_t dirtyMatrix;
} shaderdolphin_t; } shaderdolphin_t;