Rename GPUParticles attractor and collision nodes to have a 3D suffix

GPUParticles attractors and collision are currently only available in 3D.
Their 2D counterparts haven't been implemented yet, but they will use
separate nodes.
This commit is contained in:
Hugo Locurcio 2021-12-06 19:13:12 +01:00
parent ff118d7a88
commit cf936ae0dd
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
21 changed files with 188 additions and 188 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GPUParticlesAttractorBox" inherits="GPUParticlesAttractor3D" version="4.0">
<class name="GPUParticlesAttractorBox3D" inherits="GPUParticlesAttractor3D" version="4.0">
<brief_description>
</brief_description>
<description>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GPUParticlesAttractorSphere" inherits="GPUParticlesAttractor3D" version="4.0">
<class name="GPUParticlesAttractorSphere3D" inherits="GPUParticlesAttractor3D" version="4.0">
<brief_description>
</brief_description>
<description>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GPUParticlesAttractorVectorField" inherits="GPUParticlesAttractor3D" version="4.0">
<class name="GPUParticlesAttractorVectorField3D" inherits="GPUParticlesAttractor3D" version="4.0">
<brief_description>
</brief_description>
<description>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GPUParticlesCollisionBox" inherits="GPUParticlesCollision3D" version="4.0">
<class name="GPUParticlesCollisionBox3D" inherits="GPUParticlesCollision3D" version="4.0">
<brief_description>
</brief_description>
<description>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GPUParticlesCollisionHeightField" inherits="GPUParticlesCollision3D" version="4.0">
<class name="GPUParticlesCollisionHeightField3D" inherits="GPUParticlesCollision3D" version="4.0">
<brief_description>
</brief_description>
<description>
@ -13,9 +13,9 @@
</member>
<member name="follow_camera_push_ratio" type="float" setter="set_follow_camera_push_ratio" getter="get_follow_camera_push_ratio" default="0.1">
</member>
<member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionHeightField.Resolution" default="2">
<member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionHeightField3D.Resolution" default="2">
</member>
<member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="GPUParticlesCollisionHeightField.UpdateMode" default="0">
<member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="GPUParticlesCollisionHeightField3D.UpdateMode" default="0">
</member>
</members>
<constants>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GPUParticlesCollisionSDF" inherits="GPUParticlesCollision3D" version="4.0">
<class name="GPUParticlesCollisionSDF3D" inherits="GPUParticlesCollision3D" version="4.0">
<brief_description>
</brief_description>
<description>
@ -9,7 +9,7 @@
<members>
<member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)">
</member>
<member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionSDF.Resolution" default="2">
<member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionSDF3D.Resolution" default="2">
</member>
<member name="texture" type="Texture3D" setter="set_texture" getter="get_texture">
</member>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GPUParticlesCollisionSphere" inherits="GPUParticlesCollision3D" version="4.0">
<class name="GPUParticlesCollisionSphere3D" inherits="GPUParticlesCollision3D" version="4.0">
<brief_description>
</brief_description>
<description>

View File

@ -7010,7 +7010,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(PhysicalBone3DEditorPlugin(this)));
add_editor_plugin(memnew(MeshEditorPlugin(this)));
add_editor_plugin(memnew(MaterialEditorPlugin(this)));
add_editor_plugin(memnew(GPUParticlesCollisionSDFEditorPlugin(this)));
add_editor_plugin(memnew(GPUParticlesCollisionSDF3DEditorPlugin(this)));
add_editor_plugin(memnew(InputEventEditorPlugin(this)));
add_editor_plugin(memnew(SubViewportPreviewEditorPlugin(this)));
add_editor_plugin(memnew(TextControlEditorPlugin(this)));

View File

Before

Width:  |  Height:  |  Size: 431 B

After

Width:  |  Height:  |  Size: 431 B

View File

Before

Width:  |  Height:  |  Size: 612 B

After

Width:  |  Height:  |  Size: 612 B

View File

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 807 B

View File

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

View File

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 289 B

View File

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 457 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -30,7 +30,7 @@
#include "gpu_particles_collision_sdf_editor_plugin.h"
void GPUParticlesCollisionSDFEditorPlugin::_bake() {
void GPUParticlesCollisionSDF3DEditorPlugin::_bake() {
if (col_sdf) {
if (col_sdf->get_texture().is_null() || !col_sdf->get_texture()->get_path().is_resource_file()) {
String path = get_tree()->get_edited_scene_root()->get_scene_file_path();
@ -49,8 +49,8 @@ void GPUParticlesCollisionSDFEditorPlugin::_bake() {
}
}
void GPUParticlesCollisionSDFEditorPlugin::edit(Object *p_object) {
GPUParticlesCollisionSDF *s = Object::cast_to<GPUParticlesCollisionSDF>(p_object);
void GPUParticlesCollisionSDF3DEditorPlugin::edit(Object *p_object) {
GPUParticlesCollisionSDF3D *s = Object::cast_to<GPUParticlesCollisionSDF3D>(p_object);
if (!s) {
return;
}
@ -58,11 +58,11 @@ void GPUParticlesCollisionSDFEditorPlugin::edit(Object *p_object) {
col_sdf = s;
}
bool GPUParticlesCollisionSDFEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("GPUParticlesCollisionSDF");
bool GPUParticlesCollisionSDF3DEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("GPUParticlesCollisionSDF3D");
}
void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) {
void GPUParticlesCollisionSDF3DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) {
if (!col_sdf) {
return;
@ -77,7 +77,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) {
int data_size = 2;
const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0);
// Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF node is using a lot of VRAM.
// Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF3D node is using a lot of VRAM.
String size_quality;
if (size_mb < 8.0) {
size_quality = TTR("Low");
@ -101,7 +101,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) {
}
}
void GPUParticlesCollisionSDFEditorPlugin::make_visible(bool p_visible) {
void GPUParticlesCollisionSDF3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
bake_hb->show();
set_process(true);
@ -111,26 +111,26 @@ void GPUParticlesCollisionSDFEditorPlugin::make_visible(bool p_visible) {
}
}
EditorProgress *GPUParticlesCollisionSDFEditorPlugin::tmp_progress = nullptr;
EditorProgress *GPUParticlesCollisionSDF3DEditorPlugin::tmp_progress = nullptr;
void GPUParticlesCollisionSDFEditorPlugin::bake_func_begin(int p_steps) {
void GPUParticlesCollisionSDF3DEditorPlugin::bake_func_begin(int p_steps) {
ERR_FAIL_COND(tmp_progress != nullptr);
tmp_progress = memnew(EditorProgress("bake_sdf", TTR("Bake SDF"), p_steps));
}
void GPUParticlesCollisionSDFEditorPlugin::bake_func_step(int p_step, const String &p_description) {
void GPUParticlesCollisionSDF3DEditorPlugin::bake_func_step(int p_step, const String &p_description) {
ERR_FAIL_COND(tmp_progress == nullptr);
tmp_progress->step(p_description, p_step, false);
}
void GPUParticlesCollisionSDFEditorPlugin::bake_func_end() {
void GPUParticlesCollisionSDF3DEditorPlugin::bake_func_end() {
ERR_FAIL_COND(tmp_progress == nullptr);
memdelete(tmp_progress);
tmp_progress = nullptr;
}
void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String &p_path) {
void GPUParticlesCollisionSDF3DEditorPlugin::_sdf_save_path_and_bake(const String &p_path) {
probe_file->hide();
if (col_sdf) {
Ref<Image> bake_img = col_sdf->bake();
@ -168,10 +168,10 @@ void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String
}
}
void GPUParticlesCollisionSDFEditorPlugin::_bind_methods() {
void GPUParticlesCollisionSDF3DEditorPlugin::_bind_methods() {
}
GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(EditorNode *p_node) {
GPUParticlesCollisionSDF3DEditorPlugin::GPUParticlesCollisionSDF3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
bake_hb = memnew(HBoxContainer);
bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@ -180,7 +180,7 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito
bake->set_flat(true);
bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons")));
bake->set_text(TTR("Bake SDF"));
bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake));
bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDF3DEditorPlugin::_bake));
bake_hb->add_child(bake);
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb);
@ -188,14 +188,14 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito
probe_file = memnew(EditorFileDialog);
probe_file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
probe_file->add_filter("*.exr");
probe_file->connect("file_selected", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake));
probe_file->connect("file_selected", callable_mp(this, &GPUParticlesCollisionSDF3DEditorPlugin::_sdf_save_path_and_bake));
get_editor_interface()->get_base_control()->add_child(probe_file);
probe_file->set_title(TTR("Select path for SDF Texture"));
GPUParticlesCollisionSDF::bake_begin_function = bake_func_begin;
GPUParticlesCollisionSDF::bake_step_function = bake_func_step;
GPUParticlesCollisionSDF::bake_end_function = bake_func_end;
GPUParticlesCollisionSDF3D::bake_begin_function = bake_func_begin;
GPUParticlesCollisionSDF3D::bake_step_function = bake_func_step;
GPUParticlesCollisionSDF3D::bake_end_function = bake_func_end;
}
GPUParticlesCollisionSDFEditorPlugin::~GPUParticlesCollisionSDFEditorPlugin() {
GPUParticlesCollisionSDF3DEditorPlugin::~GPUParticlesCollisionSDF3DEditorPlugin() {
}

View File

@ -36,10 +36,10 @@
#include "scene/3d/gpu_particles_collision_3d.h"
#include "scene/resources/material.h"
class GPUParticlesCollisionSDFEditorPlugin : public EditorPlugin {
GDCLASS(GPUParticlesCollisionSDFEditorPlugin, EditorPlugin);
class GPUParticlesCollisionSDF3DEditorPlugin : public EditorPlugin {
GDCLASS(GPUParticlesCollisionSDF3DEditorPlugin, EditorPlugin);
GPUParticlesCollisionSDF *col_sdf;
GPUParticlesCollisionSDF3D *col_sdf;
HBoxContainer *bake_hb;
Button *bake;
@ -60,14 +60,14 @@ protected:
void _notification(int p_what);
public:
virtual String get_name() const override { return "GPUParticlesCollisionSDF"; }
virtual String get_name() const override { return "GPUParticlesCollisionSDF3D"; }
bool has_main_screen() const override { return false; }
virtual void edit(Object *p_object) override;
virtual bool handles(Object *p_object) const override;
virtual void make_visible(bool p_visible) override;
GPUParticlesCollisionSDFEditorPlugin(EditorNode *p_node);
~GPUParticlesCollisionSDFEditorPlugin();
GPUParticlesCollisionSDF3DEditorPlugin(EditorNode *p_node);
~GPUParticlesCollisionSDF3DEditorPlugin();
};
#endif // GPU_PARTICLES_COLLISION_SDF_EDITOR_PLUGIN_H

View File

@ -2767,11 +2767,11 @@ int GPUParticlesCollision3DGizmoPlugin::get_priority() const {
String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const {
const Node3D *cs = p_gizmo->get_spatial_node();
if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) {
if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) {
return "Radius";
}
if (Object::cast_to<GPUParticlesCollisionBox>(cs) || Object::cast_to<GPUParticlesAttractorBox>(cs) || Object::cast_to<GPUParticlesAttractorVectorField>(cs) || Object::cast_to<GPUParticlesCollisionSDF>(cs) || Object::cast_to<GPUParticlesCollisionHeightField>(cs)) {
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {
return "Extents";
}
@ -2781,11 +2781,11 @@ String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGiz
Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const {
const Node3D *cs = p_gizmo->get_spatial_node();
if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) {
if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) {
return p_gizmo->get_spatial_node()->call("get_radius");
}
if (Object::cast_to<GPUParticlesCollisionBox>(cs) || Object::cast_to<GPUParticlesAttractorBox>(cs) || Object::cast_to<GPUParticlesAttractorVectorField>(cs) || Object::cast_to<GPUParticlesCollisionSDF>(cs) || Object::cast_to<GPUParticlesCollisionHeightField>(cs)) {
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {
return Vector3(p_gizmo->get_spatial_node()->call("get_extents"));
}
@ -2803,7 +2803,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g
Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (Object::cast_to<GPUParticlesCollisionSphere>(sn) || Object::cast_to<GPUParticlesAttractorSphere>(sn)) {
if (Object::cast_to<GPUParticlesCollisionSphere3D>(sn) || Object::cast_to<GPUParticlesAttractorSphere3D>(sn)) {
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
float d = ra.x;
@ -2818,7 +2818,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g
sn->call("set_radius", d);
}
if (Object::cast_to<GPUParticlesCollisionBox>(sn) || Object::cast_to<GPUParticlesAttractorBox>(sn) || Object::cast_to<GPUParticlesAttractorVectorField>(sn) || Object::cast_to<GPUParticlesCollisionSDF>(sn) || Object::cast_to<GPUParticlesCollisionHeightField>(sn)) {
if (Object::cast_to<GPUParticlesCollisionBox3D>(sn) || Object::cast_to<GPUParticlesAttractorBox3D>(sn) || Object::cast_to<GPUParticlesAttractorVectorField3D>(sn) || Object::cast_to<GPUParticlesCollisionSDF3D>(sn) || Object::cast_to<GPUParticlesCollisionHeightField3D>(sn)) {
Vector3 axis;
axis[p_id] = 1.0;
Vector3 ra, rb;
@ -2841,7 +2841,7 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_g
void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
Node3D *sn = p_gizmo->get_spatial_node();
if (Object::cast_to<GPUParticlesCollisionSphere>(sn) || Object::cast_to<GPUParticlesAttractorSphere>(sn)) {
if (Object::cast_to<GPUParticlesCollisionSphere3D>(sn) || Object::cast_to<GPUParticlesAttractorSphere3D>(sn)) {
if (p_cancel) {
sn->call("set_radius", p_restore);
return;
@ -2854,7 +2854,7 @@ void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *
ur->commit_action();
}
if (Object::cast_to<GPUParticlesCollisionBox>(sn) || Object::cast_to<GPUParticlesAttractorBox>(sn) || Object::cast_to<GPUParticlesAttractorVectorField>(sn) || Object::cast_to<GPUParticlesCollisionSDF>(sn) || Object::cast_to<GPUParticlesCollisionHeightField>(sn)) {
if (Object::cast_to<GPUParticlesCollisionBox3D>(sn) || Object::cast_to<GPUParticlesAttractorBox3D>(sn) || Object::cast_to<GPUParticlesAttractorVectorField3D>(sn) || Object::cast_to<GPUParticlesCollisionSDF3D>(sn) || Object::cast_to<GPUParticlesCollisionHeightField3D>(sn)) {
if (p_cancel) {
sn->call("set_extents", p_restore);
return;
@ -2880,7 +2880,7 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Ref<Material> handles_material = get_material("handles");
if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) {
if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) {
float r = cs->call("get_radius");
Vector<Vector3> points;
@ -2922,7 +2922,7 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
if (Object::cast_to<GPUParticlesCollisionBox>(cs) || Object::cast_to<GPUParticlesAttractorBox>(cs) || Object::cast_to<GPUParticlesAttractorVectorField>(cs) || Object::cast_to<GPUParticlesCollisionSDF>(cs) || Object::cast_to<GPUParticlesCollisionHeightField>(cs)) {
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {
Vector<Vector3> lines;
AABB aabb;
aabb.position = -cs->call("get_extents").operator Vector3();
@ -2947,9 +2947,9 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_collision_segments(lines);
p_gizmo->add_handles(handles, handles_material);
GPUParticlesCollisionSDF *col_sdf = Object::cast_to<GPUParticlesCollisionSDF>(cs);
GPUParticlesCollisionSDF3D *col_sdf = Object::cast_to<GPUParticlesCollisionSDF3D>(cs);
if (col_sdf) {
static const int subdivs[GPUParticlesCollisionSDF::RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 };
static const int subdivs[GPUParticlesCollisionSDF3D::RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 };
int subdiv = subdivs[col_sdf->get_resolution()];
float cell_size = aabb.get_longest_axis_size() / subdiv;

View File

@ -62,68 +62,68 @@ GPUParticlesCollision3D::~GPUParticlesCollision3D() {
/////////////////////////////////
void GPUParticlesCollisionSphere::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesCollisionSphere::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesCollisionSphere::get_radius);
void GPUParticlesCollisionSphere3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesCollisionSphere3D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesCollisionSphere3D::get_radius);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius");
}
void GPUParticlesCollisionSphere::set_radius(real_t p_radius) {
void GPUParticlesCollisionSphere3D::set_radius(real_t p_radius) {
radius = p_radius;
RS::get_singleton()->particles_collision_set_sphere_radius(_get_collision(), radius);
update_gizmos();
}
real_t GPUParticlesCollisionSphere::get_radius() const {
real_t GPUParticlesCollisionSphere3D::get_radius() const {
return radius;
}
AABB GPUParticlesCollisionSphere::get_aabb() const {
AABB GPUParticlesCollisionSphere3D::get_aabb() const {
return AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2, radius * 2, radius * 2));
}
GPUParticlesCollisionSphere::GPUParticlesCollisionSphere() :
GPUParticlesCollisionSphere3D::GPUParticlesCollisionSphere3D() :
GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE) {
}
GPUParticlesCollisionSphere::~GPUParticlesCollisionSphere() {
GPUParticlesCollisionSphere3D::~GPUParticlesCollisionSphere3D() {
}
///////////////////////////
void GPUParticlesCollisionBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionBox::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionBox::get_extents);
void GPUParticlesCollisionBox3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionBox3D::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionBox3D::get_extents);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents");
}
void GPUParticlesCollisionBox::set_extents(const Vector3 &p_extents) {
void GPUParticlesCollisionBox3D::set_extents(const Vector3 &p_extents) {
extents = p_extents;
RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
update_gizmos();
}
Vector3 GPUParticlesCollisionBox::get_extents() const {
Vector3 GPUParticlesCollisionBox3D::get_extents() const {
return extents;
}
AABB GPUParticlesCollisionBox::get_aabb() const {
AABB GPUParticlesCollisionBox3D::get_aabb() const {
return AABB(-extents, extents * 2);
}
GPUParticlesCollisionBox::GPUParticlesCollisionBox() :
GPUParticlesCollisionBox3D::GPUParticlesCollisionBox3D() :
GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_BOX_COLLIDE) {
}
GPUParticlesCollisionBox::~GPUParticlesCollisionBox() {
GPUParticlesCollisionBox3D::~GPUParticlesCollisionBox3D() {
}
///////////////////////////////
///////////////////////////
void GPUParticlesCollisionSDF::_find_meshes(const AABB &p_aabb, Node *p_at_node, List<PlotMesh> &plot_meshes) {
void GPUParticlesCollisionSDF3D::_find_meshes(const AABB &p_aabb, Node *p_at_node, List<PlotMesh> &plot_meshes) {
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node);
if (mi && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh();
@ -172,7 +172,7 @@ void GPUParticlesCollisionSDF::_find_meshes(const AABB &p_aabb, Node *p_at_node,
}
}
uint32_t GPUParticlesCollisionSDF::_create_bvh(LocalVector<BVH> &bvh_tree, FacePos *p_faces, uint32_t p_face_count, const Face3 *p_triangles, float p_thickness) {
uint32_t GPUParticlesCollisionSDF3D::_create_bvh(LocalVector<BVH> &bvh_tree, FacePos *p_faces, uint32_t p_face_count, const Face3 *p_triangles, float p_thickness) {
if (p_face_count == 1) {
return BVH::LEAF_BIT | p_faces[0].index;
}
@ -220,7 +220,7 @@ static _FORCE_INLINE_ real_t Vector3_dot2(const Vector3 &p_vec3) {
return p_vec3.dot(p_vec3);
}
void GPUParticlesCollisionSDF::_find_closest_distance(const Vector3 &p_pos, const BVH *bvh, uint32_t p_bvh_cell, const Face3 *triangles, float thickness, float &closest_distance) {
void GPUParticlesCollisionSDF3D::_find_closest_distance(const Vector3 &p_pos, const BVH *bvh, uint32_t p_bvh_cell, const Face3 *triangles, float thickness, float &closest_distance) {
if (p_bvh_cell & BVH::LEAF_BIT) {
p_bvh_cell &= BVH::LEAF_MASK; //remove bit
@ -321,7 +321,7 @@ void GPUParticlesCollisionSDF::_find_closest_distance(const Vector3 &p_pos, cons
}
}
void GPUParticlesCollisionSDF::_compute_sdf_z(uint32_t p_z, ComputeSDFParams *params) {
void GPUParticlesCollisionSDF3D::_compute_sdf_z(uint32_t p_z, ComputeSDFParams *params) {
int32_t z_ofs = p_z * params->size.y * params->size.x;
for (int32_t y = 0; y < params->size.y; y++) {
int32_t y_ofs = z_ofs + y * params->size.x;
@ -338,10 +338,10 @@ void GPUParticlesCollisionSDF::_compute_sdf_z(uint32_t p_z, ComputeSDFParams *pa
}
}
void GPUParticlesCollisionSDF::_compute_sdf(ComputeSDFParams *params) {
void GPUParticlesCollisionSDF3D::_compute_sdf(ComputeSDFParams *params) {
ThreadWorkPool work_pool;
work_pool.init();
work_pool.begin_work(params->size.z, this, &GPUParticlesCollisionSDF::_compute_sdf_z, params);
work_pool.begin_work(params->size.z, this, &GPUParticlesCollisionSDF3D::_compute_sdf_z, params);
while (!work_pool.is_done_dispatching()) {
OS::get_singleton()->delay_usec(10000);
bake_step_function(work_pool.get_work_index() * 100 / params->size.z, "Baking SDF");
@ -350,7 +350,7 @@ void GPUParticlesCollisionSDF::_compute_sdf(ComputeSDFParams *params) {
work_pool.finish();
}
Vector3i GPUParticlesCollisionSDF::get_estimated_cell_size() const {
Vector3i GPUParticlesCollisionSDF3D::get_estimated_cell_size() const {
static const int subdivs[RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 };
int subdiv = subdivs[get_resolution()];
@ -365,7 +365,7 @@ Vector3i GPUParticlesCollisionSDF::get_estimated_cell_size() const {
return sdf_size;
}
Ref<Image> GPUParticlesCollisionSDF::bake() {
Ref<Image> GPUParticlesCollisionSDF3D::bake() {
static const int subdivs[RESOLUTION_MAX] = { 16, 32, 64, 128, 256, 512 };
int subdiv = subdivs[get_resolution()];
@ -501,18 +501,18 @@ Ref<Image> GPUParticlesCollisionSDF::bake() {
return ret;
}
void GPUParticlesCollisionSDF::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionSDF::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionSDF::get_extents);
void GPUParticlesCollisionSDF3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionSDF3D::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionSDF3D::get_extents);
ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionSDF::set_resolution);
ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionSDF::get_resolution);
ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionSDF3D::set_resolution);
ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionSDF3D::get_resolution);
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesCollisionSDF::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesCollisionSDF::get_texture);
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesCollisionSDF3D::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesCollisionSDF3D::get_texture);
ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &GPUParticlesCollisionSDF::set_thickness);
ClassDB::bind_method(D_METHOD("get_thickness"), &GPUParticlesCollisionSDF::get_thickness);
ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &GPUParticlesCollisionSDF3D::set_thickness);
ClassDB::bind_method(D_METHOD("get_thickness"), &GPUParticlesCollisionSDF3D::get_thickness);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents");
ADD_PROPERTY(PropertyInfo(Variant::INT, "resolution", PROPERTY_HINT_ENUM, "16,32,64,128,256,512"), "set_resolution", "get_resolution");
@ -528,62 +528,62 @@ void GPUParticlesCollisionSDF::_bind_methods() {
BIND_ENUM_CONSTANT(RESOLUTION_MAX);
}
void GPUParticlesCollisionSDF::set_thickness(float p_thickness) {
void GPUParticlesCollisionSDF3D::set_thickness(float p_thickness) {
thickness = p_thickness;
}
float GPUParticlesCollisionSDF::get_thickness() const {
float GPUParticlesCollisionSDF3D::get_thickness() const {
return thickness;
}
void GPUParticlesCollisionSDF::set_extents(const Vector3 &p_extents) {
void GPUParticlesCollisionSDF3D::set_extents(const Vector3 &p_extents) {
extents = p_extents;
RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
update_gizmos();
}
Vector3 GPUParticlesCollisionSDF::get_extents() const {
Vector3 GPUParticlesCollisionSDF3D::get_extents() const {
return extents;
}
void GPUParticlesCollisionSDF::set_resolution(Resolution p_resolution) {
void GPUParticlesCollisionSDF3D::set_resolution(Resolution p_resolution) {
resolution = p_resolution;
update_gizmos();
}
GPUParticlesCollisionSDF::Resolution GPUParticlesCollisionSDF::get_resolution() const {
GPUParticlesCollisionSDF3D::Resolution GPUParticlesCollisionSDF3D::get_resolution() const {
return resolution;
}
void GPUParticlesCollisionSDF::set_texture(const Ref<Texture3D> &p_texture) {
void GPUParticlesCollisionSDF3D::set_texture(const Ref<Texture3D> &p_texture) {
texture = p_texture;
RID tex = texture.is_valid() ? texture->get_rid() : RID();
RS::get_singleton()->particles_collision_set_field_texture(_get_collision(), tex);
}
Ref<Texture3D> GPUParticlesCollisionSDF::get_texture() const {
Ref<Texture3D> GPUParticlesCollisionSDF3D::get_texture() const {
return texture;
}
AABB GPUParticlesCollisionSDF::get_aabb() const {
AABB GPUParticlesCollisionSDF3D::get_aabb() const {
return AABB(-extents, extents * 2);
}
GPUParticlesCollisionSDF::BakeBeginFunc GPUParticlesCollisionSDF::bake_begin_function = nullptr;
GPUParticlesCollisionSDF::BakeStepFunc GPUParticlesCollisionSDF::bake_step_function = nullptr;
GPUParticlesCollisionSDF::BakeEndFunc GPUParticlesCollisionSDF::bake_end_function = nullptr;
GPUParticlesCollisionSDF3D::BakeBeginFunc GPUParticlesCollisionSDF3D::bake_begin_function = nullptr;
GPUParticlesCollisionSDF3D::BakeStepFunc GPUParticlesCollisionSDF3D::bake_step_function = nullptr;
GPUParticlesCollisionSDF3D::BakeEndFunc GPUParticlesCollisionSDF3D::bake_end_function = nullptr;
GPUParticlesCollisionSDF::GPUParticlesCollisionSDF() :
GPUParticlesCollisionSDF3D::GPUParticlesCollisionSDF3D() :
GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_SDF_COLLIDE) {
}
GPUParticlesCollisionSDF::~GPUParticlesCollisionSDF() {
GPUParticlesCollisionSDF3D::~GPUParticlesCollisionSDF3D() {
}
////////////////////////////
////////////////////////////
void GPUParticlesCollisionHeightField::_notification(int p_what) {
void GPUParticlesCollisionHeightField3D::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
if (update_mode == UPDATE_MODE_ALWAYS) {
RS::get_singleton()->particles_collision_height_field_update(_get_collision());
@ -628,21 +628,21 @@ void GPUParticlesCollisionHeightField::_notification(int p_what) {
}
}
void GPUParticlesCollisionHeightField::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionHeightField::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionHeightField::get_extents);
void GPUParticlesCollisionHeightField3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesCollisionHeightField3D::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesCollisionHeightField3D::get_extents);
ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionHeightField::set_resolution);
ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionHeightField::get_resolution);
ClassDB::bind_method(D_METHOD("set_resolution", "resolution"), &GPUParticlesCollisionHeightField3D::set_resolution);
ClassDB::bind_method(D_METHOD("get_resolution"), &GPUParticlesCollisionHeightField3D::get_resolution);
ClassDB::bind_method(D_METHOD("set_update_mode", "update_mode"), &GPUParticlesCollisionHeightField::set_update_mode);
ClassDB::bind_method(D_METHOD("get_update_mode"), &GPUParticlesCollisionHeightField::get_update_mode);
ClassDB::bind_method(D_METHOD("set_update_mode", "update_mode"), &GPUParticlesCollisionHeightField3D::set_update_mode);
ClassDB::bind_method(D_METHOD("get_update_mode"), &GPUParticlesCollisionHeightField3D::get_update_mode);
ClassDB::bind_method(D_METHOD("set_follow_camera_mode", "enabled"), &GPUParticlesCollisionHeightField::set_follow_camera_mode);
ClassDB::bind_method(D_METHOD("is_follow_camera_mode_enabled"), &GPUParticlesCollisionHeightField::is_follow_camera_mode_enabled);
ClassDB::bind_method(D_METHOD("set_follow_camera_mode", "enabled"), &GPUParticlesCollisionHeightField3D::set_follow_camera_mode);
ClassDB::bind_method(D_METHOD("is_follow_camera_mode_enabled"), &GPUParticlesCollisionHeightField3D::is_follow_camera_mode_enabled);
ClassDB::bind_method(D_METHOD("set_follow_camera_push_ratio", "ratio"), &GPUParticlesCollisionHeightField::set_follow_camera_push_ratio);
ClassDB::bind_method(D_METHOD("get_follow_camera_push_ratio"), &GPUParticlesCollisionHeightField::get_follow_camera_push_ratio);
ClassDB::bind_method(D_METHOD("set_follow_camera_push_ratio", "ratio"), &GPUParticlesCollisionHeightField3D::set_follow_camera_push_ratio);
ClassDB::bind_method(D_METHOD("get_follow_camera_push_ratio"), &GPUParticlesCollisionHeightField3D::get_follow_camera_push_ratio);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents");
ADD_PROPERTY(PropertyInfo(Variant::INT, "resolution", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096,8192"), "set_resolution", "get_resolution");
@ -663,63 +663,63 @@ void GPUParticlesCollisionHeightField::_bind_methods() {
BIND_ENUM_CONSTANT(UPDATE_MODE_ALWAYS);
}
void GPUParticlesCollisionHeightField::set_follow_camera_push_ratio(float p_follow_camera_push_ratio) {
void GPUParticlesCollisionHeightField3D::set_follow_camera_push_ratio(float p_follow_camera_push_ratio) {
follow_camera_push_ratio = p_follow_camera_push_ratio;
}
float GPUParticlesCollisionHeightField::get_follow_camera_push_ratio() const {
float GPUParticlesCollisionHeightField3D::get_follow_camera_push_ratio() const {
return follow_camera_push_ratio;
}
void GPUParticlesCollisionHeightField::set_extents(const Vector3 &p_extents) {
void GPUParticlesCollisionHeightField3D::set_extents(const Vector3 &p_extents) {
extents = p_extents;
RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
update_gizmos();
RS::get_singleton()->particles_collision_height_field_update(_get_collision());
}
Vector3 GPUParticlesCollisionHeightField::get_extents() const {
Vector3 GPUParticlesCollisionHeightField3D::get_extents() const {
return extents;
}
void GPUParticlesCollisionHeightField::set_resolution(Resolution p_resolution) {
void GPUParticlesCollisionHeightField3D::set_resolution(Resolution p_resolution) {
resolution = p_resolution;
RS::get_singleton()->particles_collision_set_height_field_resolution(_get_collision(), RS::ParticlesCollisionHeightfieldResolution(resolution));
update_gizmos();
RS::get_singleton()->particles_collision_height_field_update(_get_collision());
}
GPUParticlesCollisionHeightField::Resolution GPUParticlesCollisionHeightField::get_resolution() const {
GPUParticlesCollisionHeightField3D::Resolution GPUParticlesCollisionHeightField3D::get_resolution() const {
return resolution;
}
void GPUParticlesCollisionHeightField::set_update_mode(UpdateMode p_update_mode) {
void GPUParticlesCollisionHeightField3D::set_update_mode(UpdateMode p_update_mode) {
update_mode = p_update_mode;
set_process_internal(follow_camera_mode || update_mode == UPDATE_MODE_ALWAYS);
}
GPUParticlesCollisionHeightField::UpdateMode GPUParticlesCollisionHeightField::get_update_mode() const {
GPUParticlesCollisionHeightField3D::UpdateMode GPUParticlesCollisionHeightField3D::get_update_mode() const {
return update_mode;
}
void GPUParticlesCollisionHeightField::set_follow_camera_mode(bool p_enabled) {
void GPUParticlesCollisionHeightField3D::set_follow_camera_mode(bool p_enabled) {
follow_camera_mode = p_enabled;
set_process_internal(follow_camera_mode || update_mode == UPDATE_MODE_ALWAYS);
}
bool GPUParticlesCollisionHeightField::is_follow_camera_mode_enabled() const {
bool GPUParticlesCollisionHeightField3D::is_follow_camera_mode_enabled() const {
return follow_camera_mode;
}
AABB GPUParticlesCollisionHeightField::get_aabb() const {
AABB GPUParticlesCollisionHeightField3D::get_aabb() const {
return AABB(-extents, extents * 2);
}
GPUParticlesCollisionHeightField::GPUParticlesCollisionHeightField() :
GPUParticlesCollisionHeightField3D::GPUParticlesCollisionHeightField3D() :
GPUParticlesCollision3D(RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE) {
}
GPUParticlesCollisionHeightField::~GPUParticlesCollisionHeightField() {
GPUParticlesCollisionHeightField3D::~GPUParticlesCollisionHeightField3D() {
}
////////////////////////////
@ -792,104 +792,104 @@ GPUParticlesAttractor3D::~GPUParticlesAttractor3D() {
/////////////////////////////////
void GPUParticlesAttractorSphere::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesAttractorSphere::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesAttractorSphere::get_radius);
void GPUParticlesAttractorSphere3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &GPUParticlesAttractorSphere3D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &GPUParticlesAttractorSphere3D::get_radius);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius");
}
void GPUParticlesAttractorSphere::set_radius(real_t p_radius) {
void GPUParticlesAttractorSphere3D::set_radius(real_t p_radius) {
radius = p_radius;
RS::get_singleton()->particles_collision_set_sphere_radius(_get_collision(), radius);
update_gizmos();
}
real_t GPUParticlesAttractorSphere::get_radius() const {
real_t GPUParticlesAttractorSphere3D::get_radius() const {
return radius;
}
AABB GPUParticlesAttractorSphere::get_aabb() const {
AABB GPUParticlesAttractorSphere3D::get_aabb() const {
return AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2, radius * 2, radius * 2));
}
GPUParticlesAttractorSphere::GPUParticlesAttractorSphere() :
GPUParticlesAttractorSphere3D::GPUParticlesAttractorSphere3D() :
GPUParticlesAttractor3D(RS::PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT) {
}
GPUParticlesAttractorSphere::~GPUParticlesAttractorSphere() {
GPUParticlesAttractorSphere3D::~GPUParticlesAttractorSphere3D() {
}
///////////////////////////
void GPUParticlesAttractorBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorBox::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorBox::get_extents);
void GPUParticlesAttractorBox3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorBox3D::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorBox3D::get_extents);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents");
}
void GPUParticlesAttractorBox::set_extents(const Vector3 &p_extents) {
void GPUParticlesAttractorBox3D::set_extents(const Vector3 &p_extents) {
extents = p_extents;
RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
update_gizmos();
}
Vector3 GPUParticlesAttractorBox::get_extents() const {
Vector3 GPUParticlesAttractorBox3D::get_extents() const {
return extents;
}
AABB GPUParticlesAttractorBox::get_aabb() const {
AABB GPUParticlesAttractorBox3D::get_aabb() const {
return AABB(-extents, extents * 2);
}
GPUParticlesAttractorBox::GPUParticlesAttractorBox() :
GPUParticlesAttractorBox3D::GPUParticlesAttractorBox3D() :
GPUParticlesAttractor3D(RS::PARTICLES_COLLISION_TYPE_BOX_ATTRACT) {
}
GPUParticlesAttractorBox::~GPUParticlesAttractorBox() {
GPUParticlesAttractorBox3D::~GPUParticlesAttractorBox3D() {
}
///////////////////////////
void GPUParticlesAttractorVectorField::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorVectorField::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorVectorField::get_extents);
void GPUParticlesAttractorVectorField3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &GPUParticlesAttractorVectorField3D::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &GPUParticlesAttractorVectorField3D::get_extents);
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesAttractorVectorField::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesAttractorVectorField::get_texture);
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticlesAttractorVectorField3D::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticlesAttractorVectorField3D::get_texture);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_extents", "get_extents");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture3D"), "set_texture", "get_texture");
}
void GPUParticlesAttractorVectorField::set_extents(const Vector3 &p_extents) {
void GPUParticlesAttractorVectorField3D::set_extents(const Vector3 &p_extents) {
extents = p_extents;
RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents);
update_gizmos();
}
Vector3 GPUParticlesAttractorVectorField::get_extents() const {
Vector3 GPUParticlesAttractorVectorField3D::get_extents() const {
return extents;
}
void GPUParticlesAttractorVectorField::set_texture(const Ref<Texture3D> &p_texture) {
void GPUParticlesAttractorVectorField3D::set_texture(const Ref<Texture3D> &p_texture) {
texture = p_texture;
RID tex = texture.is_valid() ? texture->get_rid() : RID();
RS::get_singleton()->particles_collision_set_field_texture(_get_collision(), tex);
}
Ref<Texture3D> GPUParticlesAttractorVectorField::get_texture() const {
Ref<Texture3D> GPUParticlesAttractorVectorField3D::get_texture() const {
return texture;
}
AABB GPUParticlesAttractorVectorField::get_aabb() const {
AABB GPUParticlesAttractorVectorField3D::get_aabb() const {
return AABB(-extents, extents * 2);
}
GPUParticlesAttractorVectorField::GPUParticlesAttractorVectorField() :
GPUParticlesAttractorVectorField3D::GPUParticlesAttractorVectorField3D() :
GPUParticlesAttractor3D(RS::PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT) {
}
GPUParticlesAttractorVectorField::~GPUParticlesAttractorVectorField() {
GPUParticlesAttractorVectorField3D::~GPUParticlesAttractorVectorField3D() {
}

View File

@ -55,8 +55,8 @@ public:
~GPUParticlesCollision3D();
};
class GPUParticlesCollisionSphere : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionSphere, GPUParticlesCollision3D);
class GPUParticlesCollisionSphere3D : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionSphere3D, GPUParticlesCollision3D);
real_t radius = 1.0;
@ -69,12 +69,12 @@ public:
virtual AABB get_aabb() const override;
GPUParticlesCollisionSphere();
~GPUParticlesCollisionSphere();
GPUParticlesCollisionSphere3D();
~GPUParticlesCollisionSphere3D();
};
class GPUParticlesCollisionBox : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionBox, GPUParticlesCollision3D);
class GPUParticlesCollisionBox3D : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionBox3D, GPUParticlesCollision3D);
Vector3 extents = Vector3(1, 1, 1);
@ -87,12 +87,12 @@ public:
virtual AABB get_aabb() const override;
GPUParticlesCollisionBox();
~GPUParticlesCollisionBox();
GPUParticlesCollisionBox3D();
~GPUParticlesCollisionBox3D();
};
class GPUParticlesCollisionSDF : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionSDF, GPUParticlesCollision3D);
class GPUParticlesCollisionSDF3D : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionSDF3D, GPUParticlesCollision3D);
public:
enum Resolution {
@ -184,14 +184,14 @@ public:
static BakeStepFunc bake_step_function;
static BakeEndFunc bake_end_function;
GPUParticlesCollisionSDF();
~GPUParticlesCollisionSDF();
GPUParticlesCollisionSDF3D();
~GPUParticlesCollisionSDF3D();
};
VARIANT_ENUM_CAST(GPUParticlesCollisionSDF::Resolution)
VARIANT_ENUM_CAST(GPUParticlesCollisionSDF3D::Resolution)
class GPUParticlesCollisionHeightField : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionHeightField, GPUParticlesCollision3D);
class GPUParticlesCollisionHeightField3D : public GPUParticlesCollision3D {
GDCLASS(GPUParticlesCollisionHeightField3D, GPUParticlesCollision3D);
public:
enum Resolution {
@ -239,12 +239,12 @@ public:
virtual AABB get_aabb() const override;
GPUParticlesCollisionHeightField();
~GPUParticlesCollisionHeightField();
GPUParticlesCollisionHeightField3D();
~GPUParticlesCollisionHeightField3D();
};
VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField::Resolution)
VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField::UpdateMode)
VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField3D::Resolution)
VARIANT_ENUM_CAST(GPUParticlesCollisionHeightField3D::UpdateMode)
class GPUParticlesAttractor3D : public VisualInstance3D {
GDCLASS(GPUParticlesAttractor3D, VisualInstance3D);
@ -279,8 +279,8 @@ public:
~GPUParticlesAttractor3D();
};
class GPUParticlesAttractorSphere : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorSphere, GPUParticlesAttractor3D);
class GPUParticlesAttractorSphere3D : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorSphere3D, GPUParticlesAttractor3D);
real_t radius = 1.0;
@ -293,12 +293,12 @@ public:
virtual AABB get_aabb() const override;
GPUParticlesAttractorSphere();
~GPUParticlesAttractorSphere();
GPUParticlesAttractorSphere3D();
~GPUParticlesAttractorSphere3D();
};
class GPUParticlesAttractorBox : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorBox, GPUParticlesAttractor3D);
class GPUParticlesAttractorBox3D : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorBox3D, GPUParticlesAttractor3D);
Vector3 extents = Vector3(1, 1, 1);
@ -311,12 +311,12 @@ public:
virtual AABB get_aabb() const override;
GPUParticlesAttractorBox();
~GPUParticlesAttractorBox();
GPUParticlesAttractorBox3D();
~GPUParticlesAttractorBox3D();
};
class GPUParticlesAttractorVectorField : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorVectorField, GPUParticlesAttractor3D);
class GPUParticlesAttractorVectorField3D : public GPUParticlesAttractor3D {
GDCLASS(GPUParticlesAttractorVectorField3D, GPUParticlesAttractor3D);
Vector3 extents = Vector3(1, 1, 1);
Ref<Texture3D> texture;
@ -333,8 +333,8 @@ public:
virtual AABB get_aabb() const override;
GPUParticlesAttractorVectorField();
~GPUParticlesAttractorVectorField();
GPUParticlesAttractorVectorField3D();
~GPUParticlesAttractorVectorField3D();
};
#endif // GPU_PARTICLES_COLLISION_3D_H

View File

@ -476,14 +476,14 @@ void register_scene_types() {
GDREGISTER_VIRTUAL_CLASS(Lightmapper);
GDREGISTER_CLASS(GPUParticles3D);
GDREGISTER_VIRTUAL_CLASS(GPUParticlesCollision3D);
GDREGISTER_CLASS(GPUParticlesCollisionBox);
GDREGISTER_CLASS(GPUParticlesCollisionSphere);
GDREGISTER_CLASS(GPUParticlesCollisionSDF);
GDREGISTER_CLASS(GPUParticlesCollisionHeightField);
GDREGISTER_CLASS(GPUParticlesCollisionBox3D);
GDREGISTER_CLASS(GPUParticlesCollisionSphere3D);
GDREGISTER_CLASS(GPUParticlesCollisionSDF3D);
GDREGISTER_CLASS(GPUParticlesCollisionHeightField3D);
GDREGISTER_VIRTUAL_CLASS(GPUParticlesAttractor3D);
GDREGISTER_CLASS(GPUParticlesAttractorBox);
GDREGISTER_CLASS(GPUParticlesAttractorSphere);
GDREGISTER_CLASS(GPUParticlesAttractorVectorField);
GDREGISTER_CLASS(GPUParticlesAttractorBox3D);
GDREGISTER_CLASS(GPUParticlesAttractorSphere3D);
GDREGISTER_CLASS(GPUParticlesAttractorVectorField3D);
GDREGISTER_CLASS(CPUParticles3D);
GDREGISTER_CLASS(Position3D);