summaryrefslogtreecommitdiff
path: root/scene/3d/soft_body_3d.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/soft_body_3d.h')
-rw-r--r--scene/3d/soft_body_3d.h83
1 files changed, 44 insertions, 39 deletions
diff --git a/scene/3d/soft_body_3d.h b/scene/3d/soft_body_3d.h
index 7dd5880985..46b185a32c 100644
--- a/scene/3d/soft_body_3d.h
+++ b/scene/3d/soft_body_3d.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,21 +32,21 @@
#define SOFT_PHYSICS_BODY_H
#include "scene/3d/mesh_instance_3d.h"
+#include "servers/physics_server_3d.h"
class SoftBody3D;
-class SoftBodyRenderingServerHandler {
-
+class SoftBodyRenderingServerHandler : public RenderingServerHandler {
friend class SoftBody3D;
RID mesh;
- int surface;
+ int surface = 0;
Vector<uint8_t> buffer;
- uint32_t stride;
- uint32_t offset_vertices;
- uint32_t offset_normal;
+ uint32_t stride = 0;
+ uint32_t offset_vertices = 0;
+ uint32_t offset_normal = 0;
- uint8_t *write_buffer;
+ uint8_t *write_buffer = nullptr;
private:
SoftBodyRenderingServerHandler();
@@ -58,24 +58,29 @@ private:
void commit_changes();
public:
- void set_vertex(int p_vertex_id, const void *p_vector3);
- void set_normal(int p_vertex_id, const void *p_vector3);
- void set_aabb(const AABB &p_aabb);
+ void set_vertex(int p_vertex_id, const void *p_vector3) override;
+ void set_normal(int p_vertex_id, const void *p_vector3) override;
+ void set_aabb(const AABB &p_aabb) override;
};
class SoftBody3D : public MeshInstance3D {
GDCLASS(SoftBody3D, MeshInstance3D);
public:
+ enum DisableMode {
+ DISABLE_MODE_REMOVE,
+ DISABLE_MODE_KEEP_ACTIVE,
+ };
+
struct PinnedPoint {
- int point_index;
+ int point_index = -1;
NodePath spatial_attachment_path;
- Node3D *spatial_attachment; // Cache
+ Node3D *spatial_attachment = nullptr; // Cache
Vector3 offset;
PinnedPoint();
PinnedPoint(const PinnedPoint &obj_tocopy);
- PinnedPoint operator=(const PinnedPoint &obj);
+ PinnedPoint &operator=(const PinnedPoint &obj);
};
private:
@@ -83,22 +88,26 @@ private:
RID physics_rid;
- bool mesh_owner;
- uint32_t collision_mask;
- uint32_t collision_layer;
+ DisableMode disable_mode = DISABLE_MODE_REMOVE;
+
+ bool mesh_owner = false;
+ uint32_t collision_mask = 1;
+ uint32_t collision_layer = 1;
NodePath parent_collision_ignore;
Vector<PinnedPoint> pinned_points;
- bool simulation_started;
- bool pinned_points_cache_dirty;
+ bool simulation_started = false;
+ bool pinned_points_cache_dirty = true;
Ref<ArrayMesh> debug_mesh_cache;
- class MeshInstance3D *debug_mesh;
+ class MeshInstance3D *debug_mesh = nullptr;
- bool capture_input_on_drag;
- bool ray_pickable;
+ bool capture_input_on_drag = false;
+ bool ray_pickable = true;
void _update_pickable();
+ void _softbody_changed();
+
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
@@ -108,12 +117,10 @@ protected:
bool _set_property_pinned_points_attachment(int p_item, const String &p_what, const Variant &p_value);
bool _get_property_pinned_points(int p_item, const String &p_what, Variant &r_ret) const;
- virtual void _changed_callback(Object *p_changed, const char *p_prop);
-
void _notification(int p_what);
static void _bind_methods();
- virtual String get_configuration_warning() const;
+ TypedArray<String> get_configuration_warnings() const override;
protected:
void _update_physics_server();
@@ -123,17 +130,22 @@ public:
void prepare_physics_server();
void become_mesh_owner();
+ RID get_physics_rid() const { return physics_rid; }
+
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
void set_collision_layer(uint32_t p_layer);
uint32_t get_collision_layer() const;
- void set_collision_mask_bit(int p_bit, bool p_value);
- bool get_collision_mask_bit(int p_bit) const;
+ void set_collision_layer_value(int p_layer_number, bool p_value);
+ bool get_collision_layer_value(int p_layer_number) const;
+
+ void set_collision_mask_value(int p_layer_number, bool p_value);
+ bool get_collision_mask_value(int p_layer_number) const;
- void set_collision_layer_bit(int p_bit, bool p_value);
- bool get_collision_layer_bit(int p_bit) const;
+ void set_disable_mode(DisableMode p_mode);
+ DisableMode get_disable_mode() const;
void set_parent_collision_ignore(const NodePath &p_parent_collision_ignore);
const NodePath &get_parent_collision_ignore() const;
@@ -150,18 +162,9 @@ public:
void set_linear_stiffness(real_t p_linear_stiffness);
real_t get_linear_stiffness();
- void set_areaAngular_stiffness(real_t p_areaAngular_stiffness);
- real_t get_areaAngular_stiffness();
-
- void set_volume_stiffness(real_t p_volume_stiffness);
- real_t get_volume_stiffness();
-
void set_pressure_coefficient(real_t p_pressure_coefficient);
real_t get_pressure_coefficient();
- void set_pose_matching_coefficient(real_t p_pose_matching_coefficient);
- real_t get_pose_matching_coefficient();
-
void set_damping_coefficient(real_t p_damping_coefficient);
real_t get_damping_coefficient();
@@ -199,4 +202,6 @@ private:
int _has_pinned_point(int p_point_index) const;
};
+VARIANT_ENUM_CAST(SoftBody3D::DisableMode);
+
#endif // SOFT_PHYSICS_BODY_H