Commit 9d1a7b90 authored by Scott Duensing's avatar Scott Duensing

Optimized object update.

parent 63932bab
This diff is collapsed.
......@@ -27,6 +27,14 @@
#include "joey.h"
typedef enum {
DIRTYNESS_CLEAN = 0x00,
DIRTYNESS_SCALE = 0x01,
DIRTYNESS_ROTATE = 0x03,
DIRTYNESS_TRANSLATE = 0x07,
DIRTYNESS_ALL = 0xFF
} j3DirtynessT;
typedef float j3Matrix4x4T[4][4];
typedef struct {
......@@ -42,9 +50,12 @@ typedef struct {
} j3VertexT, j3Vector3DT;
typedef struct {
j3VertexT local; // Original vertex positions
j3VertexT world; // After rotation, scale, translation (in that order)
j3VertexT camera; // Camera space
// original -> scaled -> rotated -> translated -> camera
j3VertexT original; // Original vertex positions
j3VertexT scaled; // After scaling
j3VertexT rotated; // After rotation (aka "local")
j3VertexT translated; // After translation (aka "world")
j3VertexT camera; // Camera space
} j3CoordinatesT;
typedef struct {
......@@ -74,9 +85,7 @@ typedef struct {
j3VertexT position; // Position of object in world
j3VertexT rotation; // Rotation of object in world
j3VertexT scale; // Scale of object in world
bool positionDirty; // Did the position change?
bool rotationDirty; // Did the rotation change?
bool scaleDirty; // Did the scale change?
j3DirtynessT howDirty; // How much do we need to recalculate?
} j3ObjectT;
typedef struct {
......
......@@ -105,9 +105,9 @@ int main(void) {
for (y=0; y<world->objects[x].vertexCount; y++) {
printf(" Vertex %d: %f %f %f\n",
y,
(double)world->objects[x].vertices[y].local.x,
(double)world->objects[x].vertices[y].local.y,
(double)world->objects[x].vertices[y].local.z
(double)world->objects[x].vertices[y].original.x,
(double)world->objects[x].vertices[y].original.y,
(double)world->objects[x].vertices[y].original.z
);
}
printf(" Triangles: %d\n", world->objects[x].triangleCount);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment