Browse Source

Using ortho_ prefix for direction indices.

David Piuva 5 years ago
parent
commit
0ecf724e33

+ 1 - 1
Source/SDK/SpriteEngine/orthoAPI.cpp

@@ -84,7 +84,7 @@ void OrthoSystem::update() {
 
 
 	// Define sprite directions
 	// Define sprite directions
 	FVector3D upAxis = FVector3D(0.0f, 1.0f, 0.0f);
 	FVector3D upAxis = FVector3D(0.0f, 1.0f, 0.0f);
-	Direction worldDirections[8] = {dir315, dir45, dir135, dir225, dir0, dir90, dir180, dir270};
+	Direction worldDirections[8] = {ortho_dir315, ortho_dir45, ortho_dir135, ortho_dir225, ortho_dir0, ortho_dir90, ortho_dir180, ortho_dir270};
 	// Define approximate camera systems just to get something axis aligned
 	// Define approximate camera systems just to get something axis aligned
 	FMatrix3x3 cameraSystems[8];
 	FMatrix3x3 cameraSystems[8];
 	cameraSystems[0] = FMatrix3x3::makeAxisSystem(FVector3D(diag, this->cameraTilt, diag), upAxis);
 	cameraSystems[0] = FMatrix3x3::makeAxisSystem(FVector3D(diag, this->cameraTilt, diag), upAxis);

+ 11 - 12
Source/SDK/SpriteEngine/orthoAPI.h

@@ -7,19 +7,18 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-// TODO: Give an ortho_ prefix
 using Direction = int32_t;
 using Direction = int32_t;
-static const Direction dir360 = 8;
-static const Direction dir315 = 7;
-static const Direction dir270 = 6;
-static const Direction dir225 = 5;
-static const Direction dir180 = 4;
-static const Direction dir135 = 3;
-static const Direction dir90 = 2;
-static const Direction dir45 = 1;
-static const Direction dir0 = 0;
+static const Direction ortho_dir360 = 8;
+static const Direction ortho_dir315 = 7;
+static const Direction ortho_dir270 = 6;
+static const Direction ortho_dir225 = 5;
+static const Direction ortho_dir180 = 4;
+static const Direction ortho_dir135 = 3;
+static const Direction ortho_dir90 = 2;
+static const Direction ortho_dir45 = 1;
+static const Direction ortho_dir0 = 0;
 inline int correctDirection(Direction direction) {
 inline int correctDirection(Direction direction) {
-	return (int32_t)((uint32_t)((int32_t)direction + (dir360 * 1024)) % dir360);
+	return (int32_t)((uint32_t)((int32_t)direction + (ortho_dir360 * 1024)) % ortho_dir360);
 }
 }
 
 
 // World 3D units
 // World 3D units
@@ -46,7 +45,7 @@ public:
 	int id = -1;
 	int id = -1;
 
 
 	// Direction for rotating sprites
 	// Direction for rotating sprites
-	Direction worldDirection = dir0; // How are sprites in the world rotated relative to the camera's point of view
+	Direction worldDirection = ortho_dir0; // How are sprites in the world rotated relative to the camera's point of view
 
 
 	// The rotating transform from normal-space to world-space.
 	// The rotating transform from normal-space to world-space.
 	//   Light-space is a superset of normal-space with the origin around the camera. (Almost like camera-space but with Y straight up)
 	//   Light-space is a superset of normal-space with the origin around the camera. (Almost like camera-space but with Y straight up)

+ 1 - 1
Source/SDK/SpriteEngine/spriteAPI.cpp

@@ -228,7 +228,7 @@ public:
 public:
 public:
 	// TODO: Force frame count to a power of two or replace modulo with look-up tables in sprite configurations.
 	// TODO: Force frame count to a power of two or replace modulo with look-up tables in sprite configurations.
 	int getFrameIndex(Direction direction) {
 	int getFrameIndex(Direction direction) {
-		const int frameFromDir[dir360] = {4, 1, 5, 2, 6, 3, 7, 0};
+		const int frameFromDir[8] = {4, 1, 5, 2, 6, 3, 7, 0};
 		return frameFromDir[correctDirection(direction)] % this->frames.length();
 		return frameFromDir[correctDirection(direction)] % this->frames.length();
 	}
 	}
 };
 };

+ 8 - 8
Source/SDK/sandbox/sandbox.cpp

@@ -142,7 +142,7 @@ static int random(const int minimum, const int maximum) {
 
 
 // Variables
 // Variables
 static int brushHeight = 0; // In mini-tile units
 static int brushHeight = 0; // In mini-tile units
-static SpriteInstance spriteBrush(0, dir0, IVector3D(), true);
+static SpriteInstance spriteBrush(0, ortho_dir0, IVector3D(), true);
 static bool placingModel = false; // True when left mouse button is pressed and the direction is being assigned
 static bool placingModel = false; // True when left mouse button is pressed and the direction is being assigned
 static ModelInstance modelBrush(0, Transform3D());
 static ModelInstance modelBrush(0, Transform3D());
 static const int brushStep = ortho_miniUnitsPerTile / 32;
 static const int brushStep = ortho_miniUnitsPerTile / 32;
@@ -260,9 +260,9 @@ void sandbox_main() {
 			} else if (key == DsrKey_Delete) {
 			} else if (key == DsrKey_Delete) {
 				pressing_delete = 1;
 				pressing_delete = 1;
 			} else if (key == DsrKey_LeftArrow) {
 			} else if (key == DsrKey_LeftArrow) {
-				spriteBrush.direction = correctDirection(spriteBrush.direction + dir270);
+				spriteBrush.direction = correctDirection(spriteBrush.direction + ortho_dir270);
 			} else if (key == DsrKey_RightArrow) {
 			} else if (key == DsrKey_RightArrow) {
-				spriteBrush.direction = correctDirection(spriteBrush.direction + dir90);
+				spriteBrush.direction = correctDirection(spriteBrush.direction + ortho_dir90);
 			}
 			}
 		} else if (event.keyboardEventType == KeyboardEventType::KeyUp) {
 		} else if (event.keyboardEventType == KeyboardEventType::KeyUp) {
 			if (key == DsrKey_A) {
 			if (key == DsrKey_A) {
@@ -339,10 +339,10 @@ void sandbox_main() {
 		modelBrush.typeIndex = index;
 		modelBrush.typeIndex = index;
 	});
 	});
 	component_setPressedEvent(window_findComponentByName(window, U"leftButton"), []() {
 	component_setPressedEvent(window_findComponentByName(window, U"leftButton"), []() {
-		spriteBrush.direction = correctDirection(spriteBrush.direction + dir270);
+		spriteBrush.direction = correctDirection(spriteBrush.direction + ortho_dir270);
 	});
 	});
 	component_setPressedEvent(window_findComponentByName(window, U"rightButton"), []() {
 	component_setPressedEvent(window_findComponentByName(window, U"rightButton"), []() {
-		spriteBrush.direction = correctDirection(spriteBrush.direction + dir90);
+		spriteBrush.direction = correctDirection(spriteBrush.direction + ortho_dir90);
 	});
 	});
 	updateOverlay();
 	updateOverlay();
 
 
@@ -362,17 +362,17 @@ void sandbox_main() {
 	for (int z = -300; z < 300; z++) {
 	for (int z = -300; z < 300; z++) {
 		for (int x = -300; x < 300; x++) {
 		for (int x = -300; x < 300; x++) {
 			// The bottom floor does not have to throw shadows
 			// The bottom floor does not have to throw shadows
-			spriteWorld_addBackgroundSprite(world, SpriteInstance(random(0, 1), random(0, 3) * dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), false));
+			spriteWorld_addBackgroundSprite(world, SpriteInstance(random(0, 1), random(0, 3) * ortho_dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), false));
 		}
 		}
 	}
 	}
 	for (int z = -300; z < 300; z++) {
 	for (int z = -300; z < 300; z++) {
 		for (int x = -300; x < 300; x++) {
 		for (int x = -300; x < 300; x++) {
 			if (random(1, 4) == 1) {
 			if (random(1, 4) == 1) {
 				// Obstacles should cast shadows when possible
 				// Obstacles should cast shadows when possible
-				spriteWorld_addBackgroundSprite(world, SpriteInstance(random(2, 4), random(0, 3) * dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), true));
+				spriteWorld_addBackgroundSprite(world, SpriteInstance(random(2, 4), random(0, 3) * ortho_dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), true));
 			} else if (random(1, 20) == 1) {
 			} else if (random(1, 20) == 1) {
 				// Characters are just static geometry for testing
 				// Characters are just static geometry for testing
-				spriteWorld_addBackgroundSprite(world, SpriteInstance(5, random(0, 7) * dir45, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), true));
+				spriteWorld_addBackgroundSprite(world, SpriteInstance(5, random(0, 7) * ortho_dir45, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), true));
 			}
 			}
 		}
 		}
 	}
 	}