-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from iiMidknightii/presets
Added extrusion profiles to PathExtrude3D
- Loading branch information
Showing
27 changed files
with
4,707 additions
and
3,221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+60 KB
(110%)
addons/PathMesh3D/bin/libpath_mesh_3d.linux.template_debug.x86_64.so
Binary file not shown.
Binary file modified
BIN
+60 KB
(110%)
addons/PathMesh3D/bin/libpath_mesh_3d.linux.template_release.x86_64.so
Binary file not shown.
Binary file modified
BIN
+55.5 KB
(110%)
addons/PathMesh3D/bin/path_mesh_3d.windows.template_debug.x86_64.dll
Binary file not shown.
Binary file modified
BIN
+38 KB
(110%)
addons/PathMesh3D/bin/path_mesh_3d.windows.template_release.x86_64.dll
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="PathExtrudeProfileBase" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd"> | ||
<brief_description> | ||
A base class for defining the cross-sectional profile to extrude in a [PathExtrude3D] node. | ||
</brief_description> | ||
<description> | ||
This serves as the base for other classes that return the extruded profile in [member get_cross_section]. You can extend this class with custom scripts that override [method _generate_cross_section] in order to customize your own profile. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
<method name="_generate_cross_section" qualifiers="virtual"> | ||
<return type="PackedVector2Array" /> | ||
<description> | ||
An overrideable, virtual method for defining custom cross-sectional profiles using your own custom code. | ||
[b]Note:[/b] You must use a [code]@tool[/code] script to see the mesh build in the editor. | ||
</description> | ||
</method> | ||
<method name="get_cross_section" qualifiers="const"> | ||
<return type="PackedVector2Array" /> | ||
<description> | ||
Returns an array of Vector2s defining the cross section profile to be extruded. | ||
</description> | ||
</method> | ||
<method name="queue_update"> | ||
<return type="void" /> | ||
<description> | ||
Manually updates the cross section and alerts the [PathExtrude3D] to rebuild. This is called automatically, but you can call it manually if you need to. | ||
</description> | ||
</method> | ||
</methods> | ||
<members> | ||
<member name="flip_normals" type="bool" setter="set_flip_normals" getter="get_flip_normals" default="false"> | ||
If [code]true[/code], the extruded profile will have its faces flipped, e.g. pipes become hollow tubes. | ||
</member> | ||
</members> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="PathExtrudeProfileCircle" inherits="PathExtrudeProfileBase" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd"> | ||
<brief_description> | ||
A resource to define circular extrusion profiles for [PathExtrude3D] nodes. | ||
</brief_description> | ||
<description> | ||
This resource defines the parameters for the [PathExtrude3D] node to extrude a full or partial circular shape along its path. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<members> | ||
<member name="closed" type="bool" setter="set_closed" getter="get_closed" default="true"> | ||
If true, any circle defined with less than [code]TAU[/code] sweep will have an extra flat face to close the mesh. | ||
</member> | ||
<member name="ending_angle" type="float" setter="set_ending_angle" getter="get_ending_angle" default="6.28319"> | ||
The angle in which the profile sweep will stop. | ||
</member> | ||
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="1.0"> | ||
The distance from the center to the edges of the swept circle. | ||
</member> | ||
<member name="segments" type="int" setter="set_segments" getter="get_segments" default="32"> | ||
The number of line segments to use when constructing the circle. | ||
</member> | ||
<member name="starting_angle" type="float" setter="set_starting_angle" getter="get_starting_angle" default="0.0"> | ||
The angle in which the profile sweep will begin. | ||
</member> | ||
</members> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="PathExtrudeProfileManual" inherits="PathExtrudeProfileBase" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd"> | ||
<brief_description> | ||
A resource to define custom [PathExtrude3D] extrusion cross-section profiles. | ||
</brief_description> | ||
<description> | ||
This resource allows the user to define the cross section directly via [PackedVector2Array]. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<members> | ||
<member name="closed" type="bool" setter="set_closed" getter="get_closed" default="true"> | ||
If [code]true[/code] and [param cross_section] is not already closed, the cross-section provided to the node will have an extra flat face to close the mesh. | ||
</member> | ||
<member name="cross_section" type="PackedVector2Array" setter="set_manual_cross_section" getter="get_manual_cross_section" default="PackedVector2Array()"> | ||
The cross-sectional profile to extrude in the [PathExtrude3D]. | ||
</member> | ||
</members> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="PathExtrudeProfileRect" inherits="PathExtrudeProfileBase" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd"> | ||
<brief_description> | ||
A resource to define a rectangular extrusion profile for [PathExtrude3D]. | ||
</brief_description> | ||
<description> | ||
This resource defines the parameters to extrude a rectangle across the path in a [PathExtrude3D] node. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<members> | ||
<member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2(0, 0, 0, 0)"> | ||
The rectangle to extrude. | ||
</member> | ||
<member name="subdivisions" type="Vector2i" setter="set_subdivisions" getter="get_subdivisions" default="Vector2i(0, 0)"> | ||
The number of times in width (x) and height (y) to divide the square for better twisting. | ||
</member> | ||
</members> | ||
</class> |
48 changes: 48 additions & 0 deletions
48
src/PathMesh3D/extrude_profiles/path_extrude_profile_circle.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "path_extrude_profile_circle.hpp" | ||
|
||
using namespace godot; | ||
|
||
PackedVector2Array PathExtrudeProfileCircle::_generate_cross_section() { | ||
PackedVector2Array cs; | ||
|
||
double swept_angle = ending_angle - starting_angle; | ||
if (swept_angle <= 0.0) { | ||
return cs; | ||
} | ||
|
||
double da = swept_angle / double(segments); | ||
|
||
cs.resize(segments + 1); | ||
for (uint64_t i = 0; i <= segments; ++i) { | ||
double ang = ending_angle - da * i; | ||
cs[i] = Vector2(Math::sin(ang) * radius, Math::cos(ang) * radius); | ||
} | ||
|
||
if (closed && cs[0].distance_squared_to(cs[cs.size() - 1]) > 1.0e-6) { | ||
cs.push_back(cs[0]); | ||
} | ||
|
||
return cs; | ||
} | ||
|
||
void PathExtrudeProfileCircle::_bind_methods() { | ||
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &PathExtrudeProfileCircle::set_radius); | ||
ClassDB::bind_method(D_METHOD("get_radius"), &PathExtrudeProfileCircle::get_radius); | ||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.0,100.0,0.01,or_greater"), "set_radius", "get_radius"); | ||
|
||
ClassDB::bind_method(D_METHOD("set_starting_angle", "starting_angle"), &PathExtrudeProfileCircle::set_starting_angle); | ||
ClassDB::bind_method(D_METHOD("get_starting_angle"), &PathExtrudeProfileCircle::get_starting_angle); | ||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "starting_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.01,radians_as_degrees"), "set_starting_angle", "get_starting_angle"); | ||
|
||
ClassDB::bind_method(D_METHOD("set_ending_angle", "ending_angle"), &PathExtrudeProfileCircle::set_ending_angle); | ||
ClassDB::bind_method(D_METHOD("get_ending_angle"), &PathExtrudeProfileCircle::get_ending_angle); | ||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ending_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.01,radians_as_degrees"), "set_ending_angle", "get_ending_angle"); | ||
|
||
ClassDB::bind_method(D_METHOD("set_closed", "closed"), &PathExtrudeProfileCircle::set_closed); | ||
ClassDB::bind_method(D_METHOD("get_closed"), &PathExtrudeProfileCircle::is_closed); | ||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "closed"), "set_closed", "get_closed"); | ||
|
||
ClassDB::bind_method(D_METHOD("set_segments", "segments"), &PathExtrudeProfileCircle::set_segments); | ||
ClassDB::bind_method(D_METHOD("get_segments"), &PathExtrudeProfileCircle::get_segments); | ||
ADD_PROPERTY(PropertyInfo(Variant::INT, "segments", PROPERTY_HINT_RANGE, "0,256,1,or_greater"), "set_segments", "get_segments"); | ||
} |
71 changes: 71 additions & 0 deletions
71
src/PathMesh3D/extrude_profiles/path_extrude_profile_circle.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef PATH_EXTRUDE_PROFILE_CIRCLE_H | ||
#define PATH_EXTRUDE_PROFILE_CIRCLE_H | ||
|
||
#include "path_extrude_profile_base.hpp" | ||
|
||
namespace godot { | ||
|
||
class PathExtrudeProfileCircle : public PathExtrudeProfileBase { | ||
GDCLASS(PathExtrudeProfileCircle, PathExtrudeProfileBase) | ||
|
||
public: | ||
_ALWAYS_INLINE_ void set_radius(const double p_radius) { | ||
if (p_radius != radius) { | ||
radius = p_radius; | ||
queue_update(); | ||
} | ||
} | ||
_ALWAYS_INLINE_ double get_radius() const { return radius; } | ||
|
||
_ALWAYS_INLINE_ void set_starting_angle(const double p_starting_angle) { | ||
if (p_starting_angle != starting_angle) { | ||
starting_angle = Math::clamp(p_starting_angle, double(0.0), double(Math_TAU)); | ||
if (starting_angle > ending_angle) { | ||
ending_angle = starting_angle; | ||
} | ||
queue_update(); | ||
} | ||
} | ||
_ALWAYS_INLINE_ double get_starting_angle() const { return starting_angle; } | ||
|
||
_ALWAYS_INLINE_ void set_ending_angle(const double p_ending_angle) { | ||
if (p_ending_angle != ending_angle) { | ||
ending_angle = Math::clamp(p_ending_angle, double(0.0), double(Math_TAU)); | ||
if (ending_angle < starting_angle) { | ||
starting_angle = ending_angle; | ||
} | ||
queue_update(); | ||
} | ||
} | ||
_ALWAYS_INLINE_ double get_ending_angle() const { return ending_angle; } | ||
|
||
_ALWAYS_INLINE_ void set_closed(const bool p_closed) { | ||
if (p_closed != closed) { | ||
closed = p_closed; | ||
queue_update(); | ||
} | ||
} | ||
_ALWAYS_INLINE_ bool is_closed() const { return closed; } | ||
|
||
_ALWAYS_INLINE_ void set_segments(const uint64_t p_segments) { | ||
if (p_segments != segments && p_segments > 1) { | ||
segments = p_segments; | ||
queue_update(); | ||
} | ||
} | ||
_ALWAYS_INLINE_ uint64_t get_segments() const { return segments; } | ||
|
||
protected: | ||
virtual PackedVector2Array _generate_cross_section() override; | ||
static void _bind_methods(); | ||
|
||
private: | ||
double radius = 1.0; | ||
double starting_angle = 0.0; | ||
double ending_angle = Math_TAU; | ||
bool closed = true; | ||
uint64_t segments = 32; | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.