Get world scale by distance to origin on one axis
This commit is contained in:
1 parent
c3a68d48a7
commit
00ae43cc99
4 files changed
+42
-91
No files matched your search
@@ -378,10 +378,10 @@ static void geo_process_master_list(struct GraphNodeMasterList *node) {
|
||||
*/
|
||||
static void geo_process_ortho_projection(struct GraphNodeOrthoProjection *node) {
|
||||
if (node->node.children != NULL) {
|
||||
Mtx *mtx = alloc_display_list(sizeof(*mtx));
|
||||
f32 left = (gCurGraphNodeRoot->x - gCurGraphNodeRoot->width) / 2.0f * node->scale;
|
||||
f32 right = (gCurGraphNodeRoot->x + gCurGraphNodeRoot->width) / 2.0f * node->scale;
|
||||
f32 top = (gCurGraphNodeRoot->y - gCurGraphNodeRoot->height) / 2.0f * node->scale;
|
||||
Mtx *mtx = alloc_display_list(sizeof(*mtx));
|
||||
f32 left = (gCurGraphNodeRoot->x - gCurGraphNodeRoot->width ) / 2.0f * node->scale;
|
||||
f32 right = (gCurGraphNodeRoot->x + gCurGraphNodeRoot->width ) / 2.0f * node->scale;
|
||||
f32 top = (gCurGraphNodeRoot->y - gCurGraphNodeRoot->height) / 2.0f * node->scale;
|
||||
f32 bottom = (gCurGraphNodeRoot->y + gCurGraphNodeRoot->height) / 2.0f * node->scale;
|
||||
|
||||
guOrtho(mtx, left, right, bottom, top, -2.0f, 2.0f, 1.0f);
|
||||
@@ -411,19 +411,16 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
|
||||
#else
|
||||
sAspectRatio = (4.0f / 3.0f); // 1.33333f
|
||||
#endif
|
||||
|
||||
if (gCamera) {
|
||||
gWorldScale = ((sqr(gCamera->pos[0]) + sqr(gCamera->pos[1]) + sqr(gCamera->pos[2])) / sqr(0x2000));
|
||||
// gWorldScale = ((sqr(gCamera->pos[0]) + sqr(gCamera->pos[1]) + sqr(gCamera->pos[2])) / sqr(0x2000));
|
||||
gWorldScale = (max_3f(ABS(gCamera->pos[0]), ABS(gCamera->pos[1]), ABS(gCamera->pos[2])) / (f32)0x2000);
|
||||
gWorldScale = MAX(gWorldScale, 1.0f);
|
||||
} else {
|
||||
gWorldScale = 1.0f;
|
||||
}
|
||||
|
||||
guPerspective(mtx, &perspNorm, node->fov, sAspectRatio, (node->far/300) / gWorldScale, node->far / gWorldScale, 1.0f);
|
||||
guPerspective(mtx, &perspNorm, node->fov, sAspectRatio, ((node->far / 300) / gWorldScale), (node->far / gWorldScale), 1.0f);
|
||||
gSPPerspNormalize(gDisplayListHead++, perspNorm);
|
||||
|
||||
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
|
||||
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), (G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH));
|
||||
gCurGraphNodeCamFrustum = node;
|
||||
geo_process_node_and_siblings(node->fnNode.node.children);
|
||||
gCurGraphNodeCamFrustum = NULL;
|
||||
@@ -589,7 +586,6 @@ static void geo_process_rotation(struct GraphNodeRotation *node) {
|
||||
* For the rest it acts as a normal display list node.
|
||||
*/
|
||||
static void geo_process_scale(struct GraphNodeScale *node) {
|
||||
UNUSED Mat4 transform;
|
||||
Vec3f scaleVec;
|
||||
Mtx *mtx = alloc_display_list(sizeof(*mtx));
|
||||
|
||||
|
||||
Reference in new issue
Block a user