Browse Source

Made a method for setting the camera location.

David Piuva 5 years ago
parent
commit
01e3147fe7
2 changed files with 11 additions and 0 deletions
  1. 8 0
      Source/SDK/SpriteEngine/spriteAPI.cpp
  2. 3 0
      Source/SDK/SpriteEngine/spriteAPI.h

+ 8 - 0
Source/SDK/SpriteEngine/spriteAPI.cpp

@@ -948,6 +948,14 @@ IVector3D spriteWorld_findGroundAtPixel(SpriteWorld& world, const AlignedImageRg
 	return world->ortho.pixelToMiniPosition(pixelLocation, world->cameraIndex, world->findWorldCenter(colorBuffer));
 }
 
+void spriteWorld_setCameraLocation(SpriteWorld& world, const IVector3D miniTileLocation) {
+	MUST_EXIST(world, spriteWorld_setCameraLocation);
+	if (world->cameraLocation != miniTileLocation) {
+		world->cameraLocation = miniTileLocation;
+		world->dirtyBackground.allDirty();
+	}
+}
+
 void spriteWorld_moveCameraInPixels(SpriteWorld& world, const IVector2D& pixelOffset) {
 	MUST_EXIST(world, spriteWorld_moveCameraInPixels);
 	if (pixelOffset.x != 0 || pixelOffset.y != 0) {

+ 3 - 0
Source/SDK/SpriteEngine/spriteAPI.h

@@ -83,6 +83,9 @@ void spriteWorld_debug_octrees(SpriteWorld& world, AlignedImageRgbaU8& colorTarg
 //   The 3D system does not align with screen pixels for less than whole tile units.
 IVector3D spriteWorld_findGroundAtPixel(SpriteWorld& world, const AlignedImageRgbaU8& colorBuffer, const IVector2D& pixelLocation);
 
+// Set the camera's location directly
+void spriteWorld_setCameraLocation(SpriteWorld& world, const IVector3D miniTileLocation);
+
 // Approximates a mini-tile offset along the ground from the given pixel offset and moves the camera accordingly
 //   If the offset is too small, the camera might not move at all
 void spriteWorld_moveCameraInPixels(SpriteWorld& world, const IVector2D& pixelOffset);