Bläddra i källkod

Clamp Decal size to positive values

This prevents using negative size, while also preventing
error messages from being spammed if one of the decal's dimensions
is set to exactly 0.
Hugo Locurcio 3 år sedan
förälder
incheckning
8b1de103a8
2 ändrade filer med 3 tillägg och 2 borttagningar
  1. 2 1
      doc/classes/Decal.xml
  2. 1 1
      scene/3d/decal.cpp

+ 2 - 1
doc/classes/Decal.xml

@@ -87,7 +87,8 @@
 			[b]Note:[/b] Setting [member normal_fade] to a value greater than [code]0.0[/code] has a small performance cost due to the added normal angle computations.
 			[b]Note:[/b] Setting [member normal_fade] to a value greater than [code]0.0[/code] has a small performance cost due to the added normal angle computations.
 		</member>
 		</member>
 		<member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
 		<member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
-			Sets the size of the [AABB] used by the decal. The AABB goes from [code]-size/2[/code] to [code]size/2[/code].
+			Sets the size of the [AABB] used by the decal. All dimensions must be set to a value greater than zero (they will be clamped to [code]0.001[/code] if this is not the case). The AABB goes from [code]-size/2[/code] to [code]size/2[/code].
+			[b]Note:[/b] To improve culling efficiency of "hard surface" decals, set their [member upper_fade] and [member lower_fade] to [code]0.0[/code] and set the Y component of the [member size] as low as possible. This will reduce the decals' AABB size without affecting their appearance.
 		</member>
 		</member>
 		<member name="texture_albedo" type="Texture2D" setter="set_texture" getter="get_texture">
 		<member name="texture_albedo" type="Texture2D" setter="set_texture" getter="get_texture">
 			[Texture2D] with the base [Color] of the Decal. Either this or the [member texture_emission] must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.
 			[Texture2D] with the base [Color] of the Decal. Either this or the [member texture_emission] must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.

+ 1 - 1
scene/3d/decal.cpp

@@ -31,7 +31,7 @@
 #include "decal.h"
 #include "decal.h"
 
 
 void Decal::set_size(const Vector3 &p_size) {
 void Decal::set_size(const Vector3 &p_size) {
-	size = p_size;
+	size = Vector3(MAX(0.001, p_size.x), MAX(0.001, p_size.y), MAX(0.001, p_size.z));
 	RS::get_singleton()->decal_set_size(decal, p_size);
 	RS::get_singleton()->decal_set_size(decal, p_size);
 	update_gizmos();
 	update_gizmos();
 }
 }