浏览代码

Add a property hint for PrimitiveMesh's `uv2_padding`

Negative values are not valid and will always cause lightmap bleeding
to occur.

This also improves the documentation for the `uv2_padding` property
in the class reference.
Hugo Locurcio 2 年之前
父节点
当前提交
dc06575475
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 2 1
      doc/classes/PrimitiveMesh.xml
  2. 1 1
      scene/resources/primitive_meshes.cpp

+ 2 - 1
doc/classes/PrimitiveMesh.xml

@@ -48,7 +48,8 @@
 			The current [Material] of the primitive mesh.
 		</member>
 		<member name="uv2_padding" type="float" setter="set_uv2_padding" getter="get_uv2_padding" default="2.0">
-			If [member add_uv2] is set, specifies the padding in pixels applied along seams of the mesh. If at generation the size of the lightmap texture can't be determined, the UVs are calculated assuming a texture size of 1024x1024.
+			If [member add_uv2] is set, specifies the padding in pixels applied along seams of the mesh. Lower padding values allow making better use of the lightmap texture (resulting in higher texel density), but may introduce visible lightmap bleeding along edges.
+			If the size of the lightmap texture can't be determined when generating the mesh, UV2 is calculated assuming a texture size of 1024x1024.
 		</member>
 	</members>
 </class>

+ 1 - 1
scene/resources/primitive_meshes.cpp

@@ -257,7 +257,7 @@ void PrimitiveMesh::_bind_methods() {
 	ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, "suffix:m"), "set_custom_aabb", "get_custom_aabb");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_faces"), "set_flip_faces", "get_flip_faces");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "add_uv2"), "set_add_uv2", "get_add_uv2");
-	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "uv2_padding"), "set_uv2_padding", "get_uv2_padding");
+	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "uv2_padding", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), "set_uv2_padding", "get_uv2_padding");
 
 	GDVIRTUAL_BIND(_create_mesh_array);
 }