Bladeren bron

Another sweep of most style warnings.

David Piuva 5 jaren geleden
bovenliggende
commit
20ede118db

+ 4 - 4
Source/DFPSR/api/imageAPI.cpp

@@ -725,28 +725,28 @@ void dsr::image_dangerous_replaceDestructor(ImageRgbaU8& image, const std::funct
 	if (image) { return image->buffer->replaceDestructor(newDestructor); }
 }
 
-uint8_t* dsr::image_dangerous_getData(ImageU8& image) {
+uint8_t* dsr::image_dangerous_getData(const ImageU8& image) {
 	if (image) {
 		return imageInternal::getSafeData<uint8_t>(*image).getUnsafe();
 	} else {
 		return nullptr;
 	}
 }
-uint8_t* dsr::image_dangerous_getData(ImageU16& image) {
+uint8_t* dsr::image_dangerous_getData(const ImageU16& image) {
 	if (image) {
 		return imageInternal::getSafeData<uint8_t>(*image).getUnsafe();
 	} else {
 		return nullptr;
 	}
 }
-uint8_t* dsr::image_dangerous_getData(ImageF32& image) {
+uint8_t* dsr::image_dangerous_getData(const ImageF32& image) {
 	if (image) {
 		return imageInternal::getSafeData<uint8_t>(*image).getUnsafe();
 	} else {
 		return nullptr;
 	}
 }
-uint8_t* dsr::image_dangerous_getData(ImageRgbaU8& image) {
+uint8_t* dsr::image_dangerous_getData(const ImageRgbaU8& image) {
 	if (image) {
 		return imageInternal::getSafeData<uint8_t>(*image).getUnsafe();
 	} else {

+ 4 - 4
Source/DFPSR/api/imageAPI.h

@@ -219,10 +219,10 @@ namespace dsr {
 	// Warning! Reading elements larger than 8 bits will have lower and higher bytes stored based on local endianness
 	// Warning! Using bytes outside of the [0 .. stride * height - 1] range may cause crashes and undefined behaviour
 	// Warning! Using the pointer after the image's lifetime may cause crashes from trying to access freed memory
-	uint8_t* image_dangerous_getData(ImageU8& image);
-	uint8_t* image_dangerous_getData(ImageU16& image);
-	uint8_t* image_dangerous_getData(ImageF32& image);
-	uint8_t* image_dangerous_getData(ImageRgbaU8& image);
+	uint8_t* image_dangerous_getData(const ImageU8& image);
+	uint8_t* image_dangerous_getData(const ImageU16& image);
+	uint8_t* image_dangerous_getData(const ImageF32& image);
+	uint8_t* image_dangerous_getData(const ImageRgbaU8& image);
 }
 
 #endif

+ 1 - 1
Source/DFPSR/gui/DsrWindow.cpp

@@ -173,7 +173,7 @@ int DsrWindow::getCanvasHeight() {
 }
 
 AlignedImageF32 DsrWindow::getDepthBuffer() {
-	auto fullResolutionCanvas = this->backend->getCanvas();
+	this->backend->getCanvas();
 	int smallWidth = getCanvasWidth();
 	int smallHeight = getCanvasHeight();
 	if (!image_exists(this->depthBuffer)

+ 4 - 3
Source/DFPSR/gui/VisualComponent.cpp

@@ -50,7 +50,7 @@ IVector2D VisualComponent::getSize() const {
 	return this->location.size();
 }
 
-void VisualComponent::setRegion(FlexRegion newRegion) {
+void VisualComponent::setRegion(const FlexRegion &newRegion) {
 	this->region = newRegion;
 }
 
@@ -82,7 +82,7 @@ int VisualComponent::getIndex() const {
 	return this->index.value;
 }
 
-void VisualComponent::setLocation(IRect newLocation) {
+void VisualComponent::setLocation(const IRect &newLocation) {
 	IRect oldLocation = this->location;
 	this->location = newLocation;
 	if (oldLocation != newLocation) {
@@ -114,9 +114,10 @@ void VisualComponent::draw(ImageRgbaU8& targetImage, const IVector2D& offset) {
 	}
 }
 
-void VisualComponent::drawClipped(ImageRgbaU8& targetImage, const IVector2D& offset, const IRect& clipRegion) {
+void VisualComponent::drawClipped(ImageRgbaU8 targetImage, const IVector2D& offset, const IRect& clipRegion) {
 	IRect finalRegion = IRect::cut(clipRegion, IRect(0, 0, image_getWidth(targetImage), image_getHeight(targetImage)));
 	if (finalRegion.hasArea()) {
+		// TODO: Optimize allocation of sub-images
 		ImageRgbaU8 target = image_getSubImage(targetImage, finalRegion);
 		this->draw(target, offset - finalRegion.upperLeft());
 	}

+ 4 - 4
Source/DFPSR/gui/VisualComponent.h

@@ -84,7 +84,7 @@ public:
 protected:
 	// Generated automatically from region in applyLayout
 	IRect location;
-	void setLocation(IRect newLocation);
+	void setLocation(const IRect &newLocation);
 	// Applied reqursively while selecting the correct theme
 	VisualTheme theme;
 public:
@@ -99,7 +99,7 @@ public:
 	virtual bool isContainer() const;
 	IRect getLocation() const;
 	IVector2D getSize() const;
-	void setRegion(FlexRegion newRegion);
+	void setRegion(const FlexRegion &newRegion);
 	FlexRegion getRegion() const;
 	void setHidden(bool hidden);
 	bool getHidden() const;
@@ -144,7 +144,7 @@ public:
 	//       drawClipped(i, o, IRect(10, 0, 10, 20)) // Right half
 	//   Drawing with the whole target image as a clip region should be equivalent to a corresponding call to draw with the same targetImage and offset.
 	//     draw(i, o) <=> drawClipped(i, o, IRect(0, 0, i.width(), i.height()))
-	void drawClipped(ImageRgbaU8& targetImage, const IVector2D& offset, const IRect& clipRegion);
+	void drawClipped(ImageRgbaU8 targetImage, const IVector2D& offset, const IRect& clipRegion);
 
 // TODO: Distinguish from the generic version
 	// Add a child component
@@ -204,7 +204,7 @@ public:
 	// Override to be notified about individual attribute changes
 	virtual void changedAttribute(const ReadableString &name) {};
 	// Override to be notified about location changes
-	virtual void changedLocation(IRect &oldLocation, IRect &newLocation) {};
+	virtual void changedLocation(const IRect &oldLocation, const IRect &newLocation) {};
 	// Custom call handler to manipulate components across a generic API
 	virtual String call(const ReadableString &methodName, const ReadableString &arguments);
 };

+ 1 - 1
Source/DFPSR/gui/VisualTheme.cpp

@@ -156,7 +156,7 @@ class VisualThemeImpl {
 public:
 	MediaMachine machine;
 	// Constructor
-	VisualThemeImpl(const ReadableString& mediaCode) : machine(machine_create(mediaCode)) {}
+	explicit VisualThemeImpl(const ReadableString& mediaCode) : machine(machine_create(mediaCode)) {}
 	// Destructor
 	virtual ~VisualThemeImpl() {}
 };

+ 1 - 1
Source/DFPSR/gui/components/Button.cpp

@@ -118,7 +118,7 @@ void Button::completeAssets() {
 	}
 }
 
-void Button::changedLocation(IRect &oldLocation, IRect &newLocation) {
+void Button::changedLocation(const IRect &oldLocation, const IRect &newLocation) {
 	// If the component has changed dimensions then redraw the image
 	if (oldLocation.size() != newLocation.size()) {
 		this->hasImages = false;

+ 2 - 2
Source/DFPSR/gui/components/Button.h

@@ -53,12 +53,12 @@ private:
 public:
 	Button();
 public:
-	bool isContainer() const;
+	bool isContainer() const override;
 	void drawSelf(ImageRgbaU8& targetImage, const IRect &relativeLocation) override;
 	void receiveMouseEvent(const MouseEvent& event) override;
 	bool pointIsInside(const IVector2D& pixelPosition) override;
 	void changedTheme(VisualTheme newTheme) override;
-	void changedLocation(IRect &oldLocation, IRect &newLocation) override;
+	void changedLocation(const IRect &oldLocation, const IRect &newLocation) override;
 	void changedAttribute(const ReadableString &name) override;
 };
 

+ 1 - 1
Source/DFPSR/gui/components/Label.h

@@ -50,7 +50,7 @@ private:
 public:
 	Label();
 public:
-	bool isContainer() const;
+	bool isContainer() const override;
 	void drawSelf(ImageRgbaU8& targetImage, const IRect &relativeLocation) override;
 	bool pointIsInside(const IVector2D& pixelPosition) override;
 };

+ 1 - 1
Source/DFPSR/gui/components/ListBox.cpp

@@ -223,7 +223,7 @@ void ListBox::completeAssets() {
 	}
 }
 
-void ListBox::changedLocation(IRect &oldLocation, IRect &newLocation) {
+void ListBox::changedLocation(const IRect &oldLocation, const IRect &newLocation) {
 	// If the component has changed dimensions then redraw the image
 	if (oldLocation.size() != newLocation.size()) {
 		this->hasImages = false;

+ 2 - 2
Source/DFPSR/gui/components/ListBox.h

@@ -72,11 +72,11 @@ private:
 public:
 	ListBox();
 public:
-	bool isContainer() const;
+	bool isContainer() const override;
 	void drawSelf(ImageRgbaU8& targetImage, const IRect &relativeLocation) override;
 	void receiveMouseEvent(const MouseEvent& event) override;
 	void changedTheme(VisualTheme newTheme) override;
-	void changedLocation(IRect &oldLocation, IRect &newLocation) override;
+	void changedLocation(const IRect &oldLocation, const IRect &newLocation) override;
 	void changedAttribute(const ReadableString &name) override;
 	// The call receiver decides if the input needs to be mangled into quotes
 	String call(const ReadableString &methodName, const ReadableString &arguments) override;

+ 1 - 1
Source/DFPSR/gui/components/Panel.cpp

@@ -81,7 +81,7 @@ void Panel::completeAssets() {
 	}
 }
 
-void Panel::changedLocation(IRect &oldLocation, IRect &newLocation) {
+void Panel::changedLocation(const IRect &oldLocation, const IRect &newLocation) {
 	// If the component has changed dimensions then redraw the image
 	if (oldLocation.size() != newLocation.size()) {
 		this->hasImages = false;

+ 2 - 2
Source/DFPSR/gui/components/Panel.h

@@ -46,10 +46,10 @@ private:
 public:
 	Panel();
 public:
-	bool isContainer() const;
+	bool isContainer() const override;
 	void drawSelf(ImageRgbaU8& targetImage, const IRect &relativeLocation) override;
 	void changedTheme(VisualTheme newTheme) override;
-	void changedLocation(IRect &oldLocation, IRect &newLocation) override;
+	void changedLocation(const IRect &oldLocation, const IRect &newLocation) override;
 	void changedAttribute(const ReadableString &name) override;
 };
 

+ 2 - 2
Source/DFPSR/math/FPlane3D.h

@@ -45,8 +45,8 @@ struct FPlane3D {
 	// Returns a point on the plane intersecting the line starting at point along direction
 	// Returns +-INF or NaN when there's no point of intersection
 	FVector3D rayIntersect(const FVector3D &point, const FVector3D &direction) {
-		float offset = -(this->offset + dotProduct(this->normal, point)) / dotProduct(this->normal, direction);
-		return point + (direction * offset);
+		float relativeOffset = -(this->offset + dotProduct(this->normal, point)) / dotProduct(this->normal, direction);
+		return point + (direction * relativeOffset);
 	}
 };
 

+ 5 - 5
Source/DFPSR/math/IRect.h

@@ -54,11 +54,11 @@ public:
 	IRect expanded(int units) const { return IRect(this->l - units, this->t - units, this->w + units * 2, this->h + units * 2); }
 	// Returns the intersection between a and b or a rectangle that has no area if overlaps(a, b) is false
 	static IRect cut(const IRect &a, const IRect &b) {
-		int32_t left = std::max(a.left(), b.left());
-		int32_t top = std::max(a.top(), b.top());
-		int32_t right = std::min(a.right(), b.right());
-		int32_t bottom = std::min(a.bottom(), b.bottom());
-		return IRect(left, top, right - left, bottom - top);
+		int32_t leftSide = std::max(a.left(), b.left());
+		int32_t topSide = std::max(a.top(), b.top());
+		int32_t rightSide = std::min(a.right(), b.right());
+		int32_t bottomSide = std::min(a.bottom(), b.bottom());
+		return IRect(leftSide, topSide, rightSide - leftSide, bottomSide - topSide);
 	}
 	// Returns true iff the rectangles have an overlapping area
 	// Equivalent to hasArea(a * b)

+ 3 - 3
Source/DFPSR/render/Camera.h

@@ -82,20 +82,20 @@ public: // Do not modify individual settings without assigning whole new cameras
 	Transform3D location; // Only translation and rotation allowed. Scaling and tilting will obviously not work for cameras.
 	float widthSlope, heightSlope, invWidthSlope, invHeightSlope, imageWidth, imageHeight, nearClip, farClip;
 	ViewFrustum cullFrustum, clipFrustum;
-	Camera(bool perspective, Transform3D location, float imageWidth, float imageHeight, float widthSlope, float heightSlope, float nearClip, float farClip, ViewFrustum cullFrustum, ViewFrustum clipFrustum) :
+	Camera(bool perspective, const Transform3D &location, float imageWidth, float imageHeight, float widthSlope, float heightSlope, float nearClip, float farClip, const ViewFrustum &cullFrustum, const ViewFrustum &clipFrustum) :
 	  perspective(perspective), location(location), widthSlope(widthSlope), heightSlope(heightSlope),
 	  invWidthSlope(0.5f / widthSlope), invHeightSlope(0.5f / heightSlope), imageWidth(imageWidth), imageHeight(imageHeight),
 	  nearClip(nearClip), farClip(farClip), cullFrustum(cullFrustum), clipFrustum(clipFrustum) {}
 public:
 	// TODO: Create a procedural camera API
-	static Camera createPerspective(Transform3D location, float imageWidth, float imageHeight, float widthSlope = 1.0f, float nearClip = defaultNearClip, float farClip = defaultFarClip) {
+	static Camera createPerspective(const Transform3D &location, float imageWidth, float imageHeight, float widthSlope = 1.0f, float nearClip = defaultNearClip, float farClip = defaultFarClip) {
 		float heightSlope = widthSlope * imageHeight / imageWidth;
 		return Camera(true, location, imageWidth, imageHeight, widthSlope, heightSlope, nearClip, farClip,
 		  ViewFrustum(nearClip, farClip, widthSlope, heightSlope),
 		  ViewFrustum(nearClip, farClip, widthSlope * clipRatio, heightSlope * clipRatio));
 	}
 	// Orthogonal cameras doesn't have any near or far clip planes
-	static Camera createOrthogonal(Transform3D location, float imageWidth, float imageHeight, float halfWidth) {
+	static Camera createOrthogonal(const Transform3D &location, float imageWidth, float imageHeight, float halfWidth) {
 		float halfHeight = halfWidth * imageHeight / imageWidth;
 		return Camera(false, location, imageWidth, imageHeight, halfWidth, halfHeight, -std::numeric_limits<float>::max(), std::numeric_limits<float>::max(),
 		  ViewFrustum(halfWidth, halfHeight),

+ 2 - 2
Source/DFPSR/render/model/format/dmf1.cpp

@@ -99,7 +99,7 @@ struct ParserState {
 	Model_DMF1 *model;
 	int parserState, parserSpace, propertyIndex;
 	String lastPropertyName;
-	ParserState(Model_DMF1 *model) :
+	explicit ParserState(Model_DMF1 *model) :
 	  model(model),
 	  parserState(ParserState_WaitForStatement),
 	  parserSpace(ParserSpace_Main),
@@ -167,7 +167,7 @@ static void setProperty(ParserState &state, const String &propertyName, int inde
 			Triangle_DMF1 *lastTriangle = lastPart->getLastTriangle();
 			if (!lastTriangle) {
 				printText("Cannot define vertex data after failing to create a triangle!\n");
-			} else if (index < 0 && index > 2) {
+			} else if (index < 0 || index > 2) {
 				printText("Triangle vertex index ", index, " is out of bound 0..2!\n");
 			} else {
 				if PROPERTY_MATCH(X) {

+ 2 - 2
Source/DFPSR/render/renderCore.cpp

@@ -76,7 +76,7 @@ public:
 			this->vertexCount--;
 		}
 	}
-	void insertVertex(int newIndex, SubVertex newVertex) {
+	void insertVertex(int newIndex, const SubVertex &newVertex) {
 		// Check against buffer overflow in case of bugs from rounding errors
 		assert(newIndex >= 0);
 		assert(newIndex <= this->vertexCount);
@@ -280,7 +280,7 @@ static void drawClippedTriangle(CommandQueue *commandQueue, const TriangleDrawDa
 }
 
 // Clipping is applied automatically if needed
-void dsr::renderTriangleWithShader(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, ITriangle2D &triangle, const IRect &clipBound) {
+void dsr::renderTriangleWithShader(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, const ITriangle2D &triangle, const IRect &clipBound) {
 	// Allow small triangles to be a bit outside of the view frustum without being clipped by increasing the width and height slopes in a second test
 	// This reduces redundant clipping to improve both speed and quality
 	Visibility paddedVisibility = getTriangleVisibility(triangle, camera, true);

+ 1 - 1
Source/DFPSR/render/renderCore.h

@@ -98,7 +98,7 @@ public:
 //     Otherwise, it will waste a lot of time on rasterizing triangles that are not even visible.
 //   * targetImage must be a render target because it needs some padding for reading out of bound while rendering.
 //     ImageRgbaU8Impl::createRenderTarget will automatically padd any odd dimensions given.
-void renderTriangleWithShader(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, ITriangle2D &triangle, const IRect &clipBound);
+void renderTriangleWithShader(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, const ITriangle2D &triangle, const IRect &clipBound);
 
 // Given a set of triangle data, this method can automatically draw it using the fastest default shader.
 // Triangle culling is handled automatically but you might want to apply culling per model or something before drawing many triangles.

+ 1 - 1
Source/DFPSR/render/shader/RgbaMultiply.h

@@ -53,7 +53,7 @@ private:
 		}
 		return result;
 	}
-	Shader_RgbaMultiply(const TriangleInput &triangleInput) :
+	explicit Shader_RgbaMultiply(const TriangleInput &triangleInput) :
 	  diffuseMap(triangleInput.diffuseImage ? &(triangleInput.diffuseImage->texture) : nullptr),
 	  diffuseLayer(triangleInput.diffuseImage ? &(triangleInput.diffuseImage->texture.mips[0]) : nullptr),
 	  lightLayer(triangleInput.lightImage ? &(triangleInput.lightImage->texture.mips[0]) : nullptr),

+ 0 - 1
Source/SDK/cube/main.cpp

@@ -8,7 +8,6 @@ const String mediaPath = string_combine(U"media", file_separator());
 static BasicResourcePool pool(mediaPath);
 
 // Global variables
-std::shared_ptr<VisualComponent> mainPanel;
 float distance = 4.0f;
 bool running = true;
 int detailLevel = 2;

+ 1 - 1
Source/SDK/sandbox/sprite/Octree.h

@@ -191,7 +191,7 @@ private:
 	// Settings
 	int initialSize; // Should be around the average total world size to create the most balanced trees
 public:
-	Octree(int initialSize)
+	explicit Octree(int initialSize)
 	: initialSize(initialSize) {}
 public:
 	// Precondition: minBound <= origin <= maxBound

+ 2 - 2
Source/SDK/sandbox/sprite/orthoAPI.h

@@ -72,7 +72,7 @@ public:
 public:
 	// TODO: Find a way to avoid the default constructor
 	OrthoView() {}
-	OrthoView(int id, const IVector2D roundedXAxis, const IVector2D roundedZAxis, int yPixelsPerTile, FMatrix3x3 normalToWorldSpace, Direction worldDirection)
+	OrthoView(int id, const IVector2D roundedXAxis, const IVector2D roundedZAxis, int yPixelsPerTile, const FMatrix3x3 &normalToWorldSpace, Direction worldDirection)
 	: id(id), worldDirection(worldDirection), normalToWorldSpace(normalToWorldSpace),
 	  pixelOffsetPerTileX(roundedXAxis), pixelOffsetPerTileZ(roundedZAxis), yPixelsPerTile(yPixelsPerTile) {
 		// Pixel aligned 3D transformation matrix from tile (x, y, z) to screen (x, y, h)
@@ -188,7 +188,7 @@ public:
 	OrthoSystem(float cameraTilt, int pixelsPerTile) : cameraTilt(cameraTilt), pixelsPerTile(pixelsPerTile) {
 		this->update();
 	}
-	OrthoSystem(const ReadableString& content) {
+	explicit OrthoSystem(const ReadableString& content) {
 		config_parse_ini(content, [this](const ReadableString& block, const ReadableString& key, const ReadableString& value) {
 			if (block.length() == 0) {
 				if (string_caseInsensitiveMatch(key, U"DownTiltPerThousand")) {

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

@@ -18,7 +18,7 @@ struct SpriteConfig {
 	// Construction
 	SpriteConfig(int centerX, int centerY, int frameRows, int propertyColumns, FVector3D minBound, FVector3D maxBound)
 	: centerX(centerX), centerY(centerY), frameRows(frameRows), propertyColumns(propertyColumns), minBound(minBound), maxBound(maxBound) {}
-	SpriteConfig(const ReadableString& content) {
+	explicit SpriteConfig(const ReadableString& content) {
 		config_parse_ini(content, [this](const ReadableString& block, const ReadableString& key, const ReadableString& value) {
 			if (block.length() == 0) {
 				if (string_caseInsensitiveMatch(key, U"CenterX")) {
@@ -253,7 +253,7 @@ struct CubeMapF32 {
 	int resolution;           // The width and height of each shadow depth image or 0 if no shadows are casted
 	AlignedImageF32 cubeMap;  // A vertical sequence of reciprocal depth images for the six sides of the cube
 	ImageF32 cubeMapViews[6]; // Sub-images sharing their allocations with cubeMap as sub-images
-	CubeMapF32(int resolution) : resolution(resolution) {
+	explicit CubeMapF32(int resolution) : resolution(resolution) {
 		this->cubeMap = image_create_F32(resolution, resolution * 6);
 		for (int s = 0; s < 6; s++) {
 			this->cubeMapViews[s] = image_getSubImage(this->cubeMap, IRect(0, s * resolution, resolution, resolution));
@@ -464,7 +464,7 @@ private:
 	int shadowResolution;
 	CubeMapF32 temporaryShadowMap;
 public:
-	SpriteWorldImpl(OrthoSystem ortho, int shadowResolution)
+	SpriteWorldImpl(const OrthoSystem &ortho, int shadowResolution)
 	: ortho(ortho), passiveSprites(ortho_miniUnitsPerTile * 64), shadowResolution(shadowResolution), temporaryShadowMap(shadowResolution) {}
 public:
 	void updateBlockAt(const IRect& blockRegion, const IRect& seenRegion) {
@@ -873,9 +873,9 @@ void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText
 		// Convert height into an 8 bit channel for saving
 		for (int y = 0; y < height; y++) {
 			for (int x = 0; x < width; x++) {
-				int32_t opacity = image_readPixel_clamp(colorImage[a], x, y).alpha;
-				int32_t height = (image_readPixel_clamp(depthBuffer, x, y) - minBound.y) * heightScale;
-				image_writePixel(heightImage[a], x, y, ColorRgbaI32(height, 0, 0, opacity));
+				int32_t opacityPixel = image_readPixel_clamp(colorImage[a], x, y).alpha;
+				int32_t heightPixel = (image_readPixel_clamp(depthBuffer, x, y) - minBound.y) * heightScale;
+				image_writePixel(heightImage[a], x, y, ColorRgbaI32(heightPixel, 0, 0, opacityPixel));
 			}
 		}
 	}
@@ -937,11 +937,11 @@ void sprite_generateFromModel(const Model& visibleModel, const Model& shadowMode
 	string_save(targetPath + U".ini", configText);
 	printText("  Saved sprite atlas and config to ", targetPath, "\n\n");
 	if (debug) {
-		ImageRgbaU8 debugImage; String debugText;
+		ImageRgbaU8 debugImage; String garbageText;
 		// TODO: Show overlap between visible and shadow so that shadow outside of visible is displayed as bright red on a dark model.
 		//       The number of visible shadow pixels should be reported automatically
 		//       in an error message at the end of the total execution together with file names.
-		sprite_generateFromModel(debugImage, debugText, shadowModel, Model(), ortho, targetPath + U"Debug", 8);
+		sprite_generateFromModel(debugImage, garbageText, shadowModel, Model(), ortho, targetPath + U"Debug", 8);
 		image_save(debugImage, targetPath + U"Debug.png");
 	}
 }

+ 11 - 18
Source/SDK/sandbox/tool.cpp

@@ -190,7 +190,7 @@ struct ParserState {
 	Model model, shadow;
 	int part = -1; // Current part index for model (No index used for shadows)
 	PartSettings partSettings;
-	ParserState(const String& sourcePath) : sourcePath(sourcePath), model(model_create()), shadow(model_create()) {
+	explicit ParserState(const String& sourcePath) : sourcePath(sourcePath), model(model_create()), shadow(model_create()) {
 		model_addEmptyPart(this->shadow, U"shadow");
 	}
 };
@@ -321,8 +321,6 @@ static void generateField(ParserState& state, Shape shape, const ImageU8& height
 
 static void generateBasicShape(ParserState& state, Shape shape, const ReadableString& arg1, const ReadableString& arg2, const ReadableString& arg3, bool shadow) {
 	Transform3D system = state.partSettings.location;
-	// Create a transform function based on the shape
-	TransformFunction transform;
 	Model model = shadow ? state.shadow : state.model;
 	int part = shadow ? 0 : state.part;
 	// All shapes are centered around the axis system's origin from -0.5 to +0.5 of any given size
@@ -332,18 +330,18 @@ static void generateBasicShape(ParserState& state, Shape shape, const ReadableSt
 		float height = string_parseDouble(arg2);
 		float depth = string_parseDouble(arg3);
 		// Create a bound
-		FVector3D max = FVector3D(width, height, depth) * 0.5f;
-		FVector3D min = -max;
+		FVector3D upper = FVector3D(width, height, depth) * 0.5f;
+		FVector3D lower = -upper;
 		// Positions
 		int first = model_getNumberOfPoints(model);
-		model_addPoint(model, system.transformPoint(FVector3D(min.x, min.y, min.z))); // first + 0: Left-down-near
-		model_addPoint(model, system.transformPoint(FVector3D(min.x, min.y, max.z))); // first + 1: Left-down-far
-		model_addPoint(model, system.transformPoint(FVector3D(min.x, max.y, min.z))); // first + 2: Left-up-near
-		model_addPoint(model, system.transformPoint(FVector3D(min.x, max.y, max.z))); // first + 3: Left-up-far
-		model_addPoint(model, system.transformPoint(FVector3D(max.x, min.y, min.z))); // first + 4: Right-down-near
-		model_addPoint(model, system.transformPoint(FVector3D(max.x, min.y, max.z))); // first + 5: Right-down-far
-		model_addPoint(model, system.transformPoint(FVector3D(max.x, max.y, min.z))); // first + 6: Right-up-near
-		model_addPoint(model, system.transformPoint(FVector3D(max.x, max.y, max.z))); // first + 7: Right-up-far
+		model_addPoint(model, system.transformPoint(FVector3D(lower.x, lower.y, lower.z))); // first + 0: Left-down-near
+		model_addPoint(model, system.transformPoint(FVector3D(lower.x, lower.y, upper.z))); // first + 1: Left-down-far
+		model_addPoint(model, system.transformPoint(FVector3D(lower.x, upper.y, lower.z))); // first + 2: Left-up-near
+		model_addPoint(model, system.transformPoint(FVector3D(lower.x, upper.y, upper.z))); // first + 3: Left-up-far
+		model_addPoint(model, system.transformPoint(FVector3D(upper.x, lower.y, lower.z))); // first + 4: Right-down-near
+		model_addPoint(model, system.transformPoint(FVector3D(upper.x, lower.y, upper.z))); // first + 5: Right-down-far
+		model_addPoint(model, system.transformPoint(FVector3D(upper.x, upper.y, lower.z))); // first + 6: Right-up-near
+		model_addPoint(model, system.transformPoint(FVector3D(upper.x, upper.y, upper.z))); // first + 7: Right-up-far
 		// Polygons
 		model_addQuad(model, part, first + 3, first + 2, first + 0, first + 1); // Left quad
 		model_addQuad(model, part, first + 6, first + 7, first + 5, first + 4); // Right quad
@@ -386,11 +384,6 @@ static void generateBasicShape(ParserState& state, Shape shape, const ReadableSt
 		printText("Basic shape generation is not implemented for ", nameOfShape(shape), "!\n");
 		return;
 	}
-	if (shadow) {
-		//createGrid(state.shadow, 0, heightMap, colorMap, transform, clipZero, mergeSides, mirror, weldNormals);
-	} else {
-		//createGrid(state.model, state.part, heightMap, colorMap, transform, clipZero, mergeSides, mirror, weldNormals);
-	}
 }
 
 // Used when displaying shadow models for debugging

+ 1 - 1
Source/windowManagers/Win32Window.cpp

@@ -450,7 +450,7 @@ void Win32Window::redraw(HWND& hwnd) {
 	// Let the source bitmap use a padded width to safely handle the stride
 	// Windows require 8-byte alignment, but the image format uses 16-byte alignment.
 	int paddedWidth = dsr::image_getStride(this->canvas) / 4;
-	int width = dsr::image_getWidth(this->canvas);
+	//int width = dsr::image_getWidth(this->canvas);
 	int height = dsr::image_getHeight(this->canvas);
 	InvalidateRect(this->hwnd, NULL, false);
 	PAINTSTRUCT paintStruct;