Merge pull request #16705 from Chaosus/generate_normals_flip
Add flip switch to SurfaceTool.generate_normals
This commit is contained in:
commit
b756172bdb
@ -196,8 +196,11 @@
|
|||||||
<method name="generate_normals">
|
<method name="generate_normals">
|
||||||
<return type="void">
|
<return type="void">
|
||||||
</return>
|
</return>
|
||||||
|
<argument index="0" name="flip" type="bool" default="false">
|
||||||
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Generates normals from Vertices so you do not have to do it manually.
|
Generates normals from Vertices so you do not have to do it manually.
|
||||||
|
Setting "flip" [code]true[/code] inverts resulting normals.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="generate_tangents">
|
<method name="generate_tangents">
|
||||||
|
@ -861,7 +861,7 @@ void SurfaceTool::generate_tangents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceTool::generate_normals() {
|
void SurfaceTool::generate_normals(bool p_flip) {
|
||||||
|
|
||||||
ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES);
|
ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES);
|
||||||
|
|
||||||
@ -887,7 +887,11 @@ void SurfaceTool::generate_normals() {
|
|||||||
ERR_FAIL_COND(!v[2]);
|
ERR_FAIL_COND(!v[2]);
|
||||||
E = v[2]->next();
|
E = v[2]->next();
|
||||||
|
|
||||||
Vector3 normal = Plane(v[0]->get().vertex, v[1]->get().vertex, v[2]->get().vertex).normal;
|
Vector3 normal;
|
||||||
|
if (!p_flip)
|
||||||
|
normal = Plane(v[0]->get().vertex, v[1]->get().vertex, v[2]->get().vertex).normal;
|
||||||
|
else
|
||||||
|
normal = Plane(v[2]->get().vertex, v[1]->get().vertex, v[0]->get().vertex).normal;
|
||||||
|
|
||||||
if (smooth) {
|
if (smooth) {
|
||||||
|
|
||||||
@ -980,7 +984,7 @@ void SurfaceTool::_bind_methods() {
|
|||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("index"), &SurfaceTool::index);
|
ClassDB::bind_method(D_METHOD("index"), &SurfaceTool::index);
|
||||||
ClassDB::bind_method(D_METHOD("deindex"), &SurfaceTool::deindex);
|
ClassDB::bind_method(D_METHOD("deindex"), &SurfaceTool::deindex);
|
||||||
ClassDB::bind_method(D_METHOD("generate_normals"), &SurfaceTool::generate_normals);
|
ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &SurfaceTool::generate_normals, DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("generate_tangents"), &SurfaceTool::generate_tangents);
|
ClassDB::bind_method(D_METHOD("generate_tangents"), &SurfaceTool::generate_tangents);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("add_to_format", "flags"), &SurfaceTool::add_to_format);
|
ClassDB::bind_method(D_METHOD("add_to_format", "flags"), &SurfaceTool::add_to_format);
|
||||||
|
@ -116,7 +116,7 @@ public:
|
|||||||
|
|
||||||
void index();
|
void index();
|
||||||
void deindex();
|
void deindex();
|
||||||
void generate_normals();
|
void generate_normals(bool p_flip = false);
|
||||||
void generate_tangents();
|
void generate_tangents();
|
||||||
|
|
||||||
void add_to_format(int p_flags) { format |= p_flags; }
|
void add_to_format(int p_flags) { format |= p_flags; }
|
||||||
|
Loading…
Reference in New Issue
Block a user