summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/SCsub3
-rw-r--r--scene/3d/arvr_nodes.cpp33
-rw-r--r--scene/3d/arvr_nodes.h3
-rw-r--r--scene/3d/audio_stream_player_3d.cpp2
-rw-r--r--scene/3d/camera.cpp2
-rw-r--r--scene/3d/collision_polygon.cpp4
-rw-r--r--scene/3d/collision_polygon.h4
-rw-r--r--scene/3d/gi_probe.cpp87
-rw-r--r--scene/3d/gi_probe.h22
-rw-r--r--scene/3d/immediate_geometry.cpp2
-rw-r--r--scene/3d/immediate_geometry.h4
-rw-r--r--scene/3d/light.cpp29
-rw-r--r--scene/3d/light.h3
-rw-r--r--scene/3d/mesh_instance.cpp4
-rw-r--r--scene/3d/mesh_instance.h2
-rw-r--r--scene/3d/multimesh_instance.cpp4
-rw-r--r--scene/3d/multimesh_instance.h2
-rw-r--r--scene/3d/particles.cpp360
-rw-r--r--scene/3d/particles.h12
-rw-r--r--scene/3d/path.cpp52
-rw-r--r--scene/3d/path.h5
-rw-r--r--scene/3d/physics_body.cpp20
-rw-r--r--scene/3d/physics_joint.cpp31
-rw-r--r--scene/3d/portal.cpp2
-rw-r--r--scene/3d/portal.h4
-rw-r--r--scene/3d/ray_cast.cpp36
-rw-r--r--scene/3d/ray_cast.h9
-rw-r--r--scene/3d/reflection_probe.cpp4
-rw-r--r--scene/3d/reflection_probe.h2
-rw-r--r--scene/3d/room_instance.cpp6
-rw-r--r--scene/3d/room_instance.h2
-rw-r--r--scene/3d/spatial.cpp32
-rw-r--r--scene/3d/spatial.h8
-rw-r--r--scene/3d/sprite_3d.cpp6
-rw-r--r--scene/3d/sprite_3d.h6
-rw-r--r--scene/3d/visibility_notifier.cpp10
-rw-r--r--scene/3d/visibility_notifier.h6
-rw-r--r--scene/3d/visual_instance.cpp2
-rw-r--r--scene/3d/visual_instance.h4
39 files changed, 446 insertions, 383 deletions
diff --git a/scene/3d/SCsub b/scene/3d/SCsub
index 72739b527e..4008f4f196 100644
--- a/scene/3d/SCsub
+++ b/scene/3d/SCsub
@@ -7,6 +7,9 @@ if env['disable_3d']:
env.scene_sources.append("3d/spatial.cpp")
env.scene_sources.append("3d/skeleton.cpp")
+ env.scene_sources.append("3d/particles.cpp")
+ env.scene_sources.append("3d/visual_instance.cpp")
+ env.scene_sources.append("3d/scenario_fx.cpp")
else:
env.add_source_files(env.scene_sources, "*.cpp")
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index c6b6c02129..e1e0b9b1ce 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -204,7 +204,7 @@ void ARVRController::_notification(int p_what) {
int mask = 1;
// check button states
for (int i = 0; i < 16; i++) {
- bool was_pressed = (button_states && mask) == mask;
+ bool was_pressed = (button_states & mask) == mask;
bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, i);
if (!was_pressed && is_pressed) {
@@ -231,7 +231,7 @@ void ARVRController::_notification(int p_what) {
void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id);
ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id"), "set_controller_id", "get_controller_id");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "1,32,1"), "set_controller_id", "get_controller_id");
ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name);
// passthroughs to information about our related joystick
@@ -242,6 +242,10 @@ void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active);
ClassDB::bind_method(D_METHOD("get_hand"), &ARVRController::get_hand);
+ ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble);
+ ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
+
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
};
@@ -299,6 +303,30 @@ float ARVRController::get_joystick_axis(int p_axis) const {
return Input::get_singleton()->get_joy_axis(joy_id, p_axis);
};
+real_t ARVRController::get_rumble() const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, 0.0);
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker == NULL) {
+ return 0.0;
+ };
+
+ return tracker->get_rumble();
+};
+
+void ARVRController::set_rumble(real_t p_rumble) {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker != NULL) {
+ tracker->set_rumble(p_rumble);
+ };
+};
+
bool ARVRController::get_is_active() const {
return is_active;
};
@@ -336,6 +364,7 @@ String ARVRController::get_configuration_warning() const {
ARVRController::ARVRController() {
controller_id = 0;
is_active = true;
+ button_states = 0;
};
ARVRController::~ARVRController(){
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index e0ccfab58b..6e940351f2 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -89,6 +89,9 @@ public:
int is_button_pressed(int p_button) const;
float get_joystick_axis(int p_axis) const;
+ real_t get_rumble() const;
+ void set_rumble(real_t p_rumble);
+
bool get_is_active() const;
ARVRPositionalTracker::TrackerHand get_hand() const;
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 3c92814c87..ad1a15f363 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -869,7 +869,7 @@ void AudioStreamPlayer3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation_filter_cutoff_hz", PROPERTY_HINT_RANGE, "50,50000,1"), "set_attenuation_filter_cutoff_hz", "get_attenuation_filter_cutoff_hz");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation_filter_db", PROPERTY_HINT_RANGE, "-80,0,0.1"), "set_attenuation_filter_db", "get_attenuation_filter_db");
ADD_GROUP("Doppler", "doppler_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "doppler_tracking", PROPERTY_HINT_ENUM, "Disabled,Idle,Fixed"), "set_doppler_tracking", "get_doppler_tracking");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "doppler_tracking", PROPERTY_HINT_ENUM, "Disabled,Idle,Physics"), "set_doppler_tracking", "get_doppler_tracking");
BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_DISTANCE);
BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_SQUARE_DISTANCE);
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 7baf9a9deb..8c7d0c23c3 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -175,7 +175,7 @@ void Camera::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"));
p_list->push_back(PropertyInfo(Variant::REAL, "h_offset"));
p_list->push_back(PropertyInfo(Variant::REAL, "v_offset"));
- p_list->push_back(PropertyInfo(Variant::INT, "doppler/tracking", PROPERTY_HINT_ENUM, "Disabled,Idle,Fixed"));
+ p_list->push_back(PropertyInfo(Variant::INT, "doppler/tracking", PROPERTY_HINT_ENUM, "Disabled,Idle,Physics"));
}
void Camera::_update_camera() {
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index 382cbb8f38..a6d812efec 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -117,7 +117,7 @@ Vector<Point2> CollisionPolygon::get_polygon() const {
return polygon;
}
-Rect3 CollisionPolygon::get_item_rect() const {
+AABB CollisionPolygon::get_item_rect() const {
return aabb;
}
@@ -176,7 +176,7 @@ void CollisionPolygon::_bind_methods() {
CollisionPolygon::CollisionPolygon() {
- aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
+ aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
depth = 1.0;
set_notify_local_transform(true);
parent = NULL;
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h
index dbed1d7154..14d8c3aba6 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon.h
@@ -40,7 +40,7 @@ class CollisionPolygon : public Spatial {
protected:
float depth;
- Rect3 aabb;
+ AABB aabb;
Vector<Point2> polygon;
uint32_t owner_id;
@@ -64,7 +64,7 @@ public:
void set_disabled(bool p_disabled);
bool is_disabled() const;
- virtual Rect3 get_item_rect() const;
+ virtual AABB get_item_rect() const;
String get_configuration_warning() const;
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 9d55a82824..05d5d52d28 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -31,12 +31,12 @@
#include "mesh_instance.h"
-void GIProbeData::set_bounds(const Rect3 &p_bounds) {
+void GIProbeData::set_bounds(const AABB &p_bounds) {
VS::get_singleton()->gi_probe_set_bounds(probe, p_bounds);
}
-Rect3 GIProbeData::get_bounds() const {
+AABB GIProbeData::get_bounds() const {
return VS::get_singleton()->gi_probe_get_bounds(probe);
}
@@ -180,7 +180,7 @@ void GIProbeData::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_compress", "compress"), &GIProbeData::set_compress);
ClassDB::bind_method(D_METHOD("is_compressed"), &GIProbeData::is_compressed);
- ADD_PROPERTY(PropertyInfo(Variant::RECT3, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds");
+ ADD_PROPERTY(PropertyInfo(Variant::AABB, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "to_cell_xform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_to_cell_xform", "get_to_cell_xform");
@@ -410,7 +410,7 @@ static bool planeBoxOverlap(Vector3 normal, float d, Vector3 maxbox) {
rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
if (min > rad || max < -rad) return false;
-/*======================== Z-tests ========================*/
+ /*======================== Z-tests ========================*/
#define AXISTEST_Z12(a, b, fa, fb) \
p1 = a * v1.x - b * v1.y; \
@@ -542,7 +542,7 @@ static _FORCE_INLINE_ Vector2 get_uv(const Vector3 &p_pos, const Vector3 *p_vtx,
return p_uv[0] * u + p_uv[1] * v + p_uv[2] * w;
}
-void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker) {
+void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker) {
if (p_level == p_baker->cell_subdiv - 1) {
//plot the face by guessing it's albedo and emission value
@@ -702,7 +702,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons
int half = (1 << (p_baker->cell_subdiv - 1)) >> (p_level + 1);
for (int i = 0; i < 8; i++) {
- Rect3 aabb = p_aabb;
+ AABB aabb = p_aabb;
aabb.size *= 0.5;
int nx = p_x;
@@ -726,7 +726,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons
continue;
{
- Rect3 test_aabb = aabb;
+ AABB test_aabb = aabb;
//test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time
Vector3 qsize = test_aabb.size * 0.5; //quarter size, for fast aabb test
@@ -891,7 +891,7 @@ void GIProbe::_fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Bak
}
}
-Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_color) {
+Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add) {
Vector<Color> ret;
@@ -899,7 +899,7 @@ Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_colo
ret.resize(bake_texture_size * bake_texture_size);
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
- ret[i] = p_color;
+ ret[i] = p_color_add;
}
return ret;
@@ -919,9 +919,10 @@ Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_colo
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
Color c;
- c.r = (r[i * 4 + 0] / 255.0) * p_color.r;
- c.g = (r[i * 4 + 1] / 255.0) * p_color.g;
- c.b = (r[i * 4 + 2] / 255.0) * p_color.b;
+ c.r = (r[i * 4 + 0] / 255.0) * p_color_mul.r + p_color_add.r;
+ c.g = (r[i * 4 + 1] / 255.0) * p_color_mul.g + p_color_add.g;
+ c.b = (r[i * 4 + 2] / 255.0) * p_color_mul.b + p_color_add.b;
+
c.a = r[i * 4 + 3] / 255.0;
ret[i] = c;
@@ -951,17 +952,15 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
if (albedo_tex.is_valid()) {
img_albedo = albedo_tex->get_data();
+ mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo(), Color(0, 0, 0)); // albedo texture, color is multiplicative
} else {
+ mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive
}
- mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo());
-
- Ref<ImageTexture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION);
+ Ref<Texture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION);
Color emission_col = mat->get_emission();
- emission_col.r *= mat->get_emission_energy();
- emission_col.g *= mat->get_emission_energy();
- emission_col.b *= mat->get_emission_energy();
+ float emission_energy = mat->get_emission_energy();
Ref<Image> img_emission;
@@ -970,13 +969,17 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
img_emission = emission_tex->get_data();
}
- mc.emission = _get_bake_texture(img_emission, emission_col);
+ if (mat->get_emission_operator() == SpatialMaterial::EMISSION_OP_ADD) {
+ mc.emission = _get_bake_texture(img_emission, Color(1, 1, 1) * emission_energy, emission_col * emission_energy);
+ } else {
+ mc.emission = _get_bake_texture(img_emission, emission_col * emission_energy, Color(0, 0, 0));
+ }
} else {
Ref<Image> empty;
- mc.albedo = _get_bake_texture(empty, Color(0.7, 0.7, 0.7));
- mc.emission = _get_bake_texture(empty, Color(0, 0, 0));
+ mc.albedo = _get_bake_texture(empty, Color(0, 0, 0), Color(1, 1, 1));
+ mc.emission = _get_bake_texture(empty, Color(0, 0, 0), Color(0, 0, 0));
}
p_baker->material_cache[p_material] = mc;
@@ -1080,11 +1083,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
- Rect3 aabb = mesh->get_aabb();
+ AABB aabb = mesh->get_aabb();
Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform();
- if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) {
Baker::PlotMesh pm;
pm.local_xform = xf;
pm.mesh = mesh;
@@ -1110,11 +1113,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
if (!mesh.is_valid())
continue;
- Rect3 aabb = mesh->get_aabb();
+ AABB aabb = mesh->get_aabb();
Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
- if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) {
Baker::PlotMesh pm;
pm.local_xform = xf;
pm.mesh = mesh;
@@ -1134,6 +1137,10 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
}
}
+GIProbe::BakeBeginFunc GIProbe::bake_begin_function = NULL;
+GIProbe::BakeStepFunc GIProbe::bake_step_function = NULL;
+GIProbe::BakeEndFunc GIProbe::bake_end_function = NULL;
+
void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
Baker baker;
@@ -1144,7 +1151,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
baker.bake_cells.resize(1);
//find out the actual real bounds, power of 2, which gets the highest subdivision
- baker.po2_bounds = Rect3(-extents, extents * 2.0);
+ baker.po2_bounds = AABB(-extents, extents * 2.0);
int longest_axis = baker.po2_bounds.get_longest_axis_index();
baker.axis_cell_size[longest_axis] = (1 << (baker.cell_subdiv - 1));
baker.leaf_voxel_count = 0;
@@ -1177,14 +1184,25 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
_find_meshes(p_from_node ? p_from_node : get_parent(), &baker);
+ if (bake_begin_function) {
+ bake_begin_function(baker.mesh_list.size() + 1);
+ }
+
int pmc = 0;
for (List<Baker::PlotMesh>::Element *E = baker.mesh_list.front(); E; E = E->next()) {
- print_line("plotting mesh " + itos(pmc++) + "/" + itos(baker.mesh_list.size()));
+ if (bake_step_function) {
+ bake_step_function(pmc, RTR("Plotting Meshes") + " " + itos(pmc) + "/" + itos(baker.mesh_list.size()));
+ }
+
+ pmc++;
_plot_mesh(E->get().local_xform, E->get().mesh, &baker, E->get().instance_materials, E->get().override_material);
}
+ if (bake_step_function) {
+ bake_step_function(pmc++, RTR("Finishing Plot"));
+ }
_fixup_plot(0, 0, 0, 0, 0, &baker);
@@ -1268,7 +1286,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
Ref<GIProbeData> probe_data;
probe_data.instance();
- probe_data->set_bounds(Rect3(-extents, extents * 2.0));
+ probe_data->set_bounds(AABB(-extents, extents * 2.0));
probe_data->set_cell_size(baker.po2_bounds.size[longest_axis] / baker.axis_cell_size[longest_axis]);
probe_data->set_dynamic_data(data);
probe_data->set_dynamic_range(dynamic_range);
@@ -1282,9 +1300,13 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
set_probe_data(probe_data);
}
+
+ if (bake_end_function) {
+ bake_end_function();
+ }
}
-void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) {
+void GIProbe::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) {
if (p_level == p_baker->cell_subdiv - 1) {
@@ -1306,7 +1328,7 @@ void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<Multi
if (p_baker->bake_cells[p_idx].childs[i] == Baker::CHILD_EMPTY)
continue;
- Rect3 aabb = p_aabb;
+ AABB aabb = p_aabb;
aabb.size *= 0.5;
if (i & 1)
@@ -1418,9 +1440,9 @@ void GIProbe::_debug_bake() {
bake(NULL, true);
}
-Rect3 GIProbe::get_aabb() const {
+AABB GIProbe::get_aabb() const {
- return Rect3(-extents, extents * 2);
+ return AABB(-extents, extents * 2);
}
PoolVector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const {
@@ -1478,6 +1500,7 @@ void GIProbe::_bind_methods() {
BIND_ENUM_CONSTANT(SUBDIV_64);
BIND_ENUM_CONSTANT(SUBDIV_128);
BIND_ENUM_CONSTANT(SUBDIV_256);
+ BIND_ENUM_CONSTANT(SUBDIV_512);
BIND_ENUM_CONSTANT(SUBDIV_MAX);
}
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index 5a06984a47..324ff8e917 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -43,8 +43,8 @@ protected:
static void _bind_methods();
public:
- void set_bounds(const Rect3 &p_bounds);
- Rect3 get_bounds() const;
+ void set_bounds(const AABB &p_bounds);
+ AABB get_bounds() const;
void set_cell_size(float p_size);
float get_cell_size() const;
@@ -95,6 +95,10 @@ public:
};
+ typedef void (*BakeBeginFunc)(int);
+ typedef void (*BakeStepFunc)(int, const String &);
+ typedef void (*BakeEndFunc)();
+
private:
//stuff used for bake
struct Baker {
@@ -142,7 +146,7 @@ private:
MaterialCache _get_material_cache(Ref<Material> p_material);
int leaf_voxel_count;
- Rect3 po2_bounds;
+ AABB po2_bounds;
int axis_cell_size[3];
struct PlotMesh {
@@ -174,14 +178,14 @@ private:
int color_scan_cell_width;
int bake_texture_size;
- Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color);
+ Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add);
Baker::MaterialCache _get_material_cache(Ref<Material> p_material, Baker *p_baker);
- void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker);
+ void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker);
void _plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material);
void _find_meshes(Node *p_at_node, Baker *p_baker);
void _fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Baker *p_baker);
- void _debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker);
+ void _debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker);
void _create_debug_mesh(Baker *p_baker);
void _debug_bake();
@@ -190,6 +194,10 @@ protected:
static void _bind_methods();
public:
+ static BakeBeginFunc bake_begin_function;
+ static BakeStepFunc bake_step_function;
+ static BakeEndFunc bake_end_function;
+
void set_probe_data(const Ref<GIProbeData> &p_data);
Ref<GIProbeData> get_probe_data() const;
@@ -222,7 +230,7 @@ public:
void bake(Node *p_from_node = NULL, bool p_create_visual_debug = false);
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
GIProbe();
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index 11f7efe066..092ed8f0b2 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -85,7 +85,7 @@ void ImmediateGeometry::clear() {
cached_textures.clear();
}
-Rect3 ImmediateGeometry::get_aabb() const {
+AABB ImmediateGeometry::get_aabb() const {
return aabb;
}
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index 93ef726c6d..1ff4e05e82 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -42,7 +42,7 @@ class ImmediateGeometry : public GeometryInstance {
// in VisualServer from becoming invalid if the texture is no longer used
List<Ref<Texture> > cached_textures;
bool empty;
- Rect3 aabb;
+ AABB aabb;
protected:
static void _bind_methods();
@@ -62,7 +62,7 @@ public:
void add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv = true);
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
ImmediateGeometry();
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index b7cd9bd2dc..126c07f0be 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -117,24 +117,24 @@ bool Light::get_shadow_reverse_cull_face() const {
return reverse_cull;
}
-Rect3 Light::get_aabb() const {
+AABB Light::get_aabb() const {
if (type == VisualServer::LIGHT_DIRECTIONAL) {
- return Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
+ return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
} else if (type == VisualServer::LIGHT_OMNI) {
- return Rect3(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]);
+ return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]);
} else if (type == VisualServer::LIGHT_SPOT) {
float len = param[PARAM_RANGE];
float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len;
- return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
+ return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
}
- return Rect3();
+ return AABB();
}
PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
@@ -222,6 +222,7 @@ void Light::_bind_methods() {
ADD_GROUP("Light", "light_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_color", "get_color");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_ENERGY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_indirect_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_INDIRECT_ENERGY);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "light_negative"), "set_negative", "is_negative");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SPECULAR);
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
@@ -236,6 +237,7 @@ void Light::_bind_methods() {
ADD_GROUP("", "");
BIND_ENUM_CONSTANT(PARAM_ENERGY);
+ BIND_ENUM_CONSTANT(PARAM_INDIRECT_ENERGY);
BIND_ENUM_CONSTANT(PARAM_SPECULAR);
BIND_ENUM_CONSTANT(PARAM_RANGE);
BIND_ENUM_CONSTANT(PARAM_ATTENUATION);
@@ -248,14 +250,20 @@ void Light::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_3_OFFSET);
BIND_ENUM_CONSTANT(PARAM_SHADOW_NORMAL_BIAS);
BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS);
-
+ BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS_SPLIT_SCALE);
BIND_ENUM_CONSTANT(PARAM_MAX);
}
Light::Light(VisualServer::LightType p_type) {
type = p_type;
- light = VisualServer::get_singleton()->light_create(p_type);
+ switch (p_type) {
+ case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break;
+ case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break;
+ case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break;
+ default: {};
+ }
+
VS::get_singleton()->instance_set_base(get_instance(), light);
reverse_cull = false;
@@ -267,6 +275,7 @@ Light::Light(VisualServer::LightType p_type) {
set_cull_mask(0xFFFFFFFF);
set_param(PARAM_ENERGY, 1);
+ set_param(PARAM_INDIRECT_ENERGY, 1);
set_param(PARAM_SPECULAR, 0.5);
set_param(PARAM_RANGE, 5);
set_param(PARAM_ATTENUATION, 1);
@@ -369,12 +378,6 @@ DirectionalLight::DirectionalLight()
set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE);
blend_splits = false;
-
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint())
- // Create light with a default natural "sun" orientation in editor, instead of looking horizontally on X
- set_rotation_in_degrees(Vector3(-50, 25, 30));
-#endif
}
void OmniLight::set_shadow_mode(ShadowMode p_mode) {
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 2f3ac8a5e7..8514b429ec 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -46,6 +46,7 @@ class Light : public VisualInstance {
public:
enum Param {
PARAM_ENERGY = VS::LIGHT_PARAM_ENERGY,
+ PARAM_INDIRECT_ENERGY = VS::LIGHT_PARAM_INDIRECT_ENERGY,
PARAM_SPECULAR = VS::LIGHT_PARAM_SPECULAR,
PARAM_RANGE = VS::LIGHT_PARAM_RANGE,
PARAM_ATTENUATION = VS::LIGHT_PARAM_ATTENUATION,
@@ -113,7 +114,7 @@ public:
void set_shadow_reverse_cull_face(bool p_enable);
bool get_shadow_reverse_cull_face() const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
Light();
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index c8215971c4..1e52ccc6e0 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -165,12 +165,12 @@ NodePath MeshInstance::get_skeleton_path() {
return skeleton_path;
}
-Rect3 MeshInstance::get_aabb() const {
+AABB MeshInstance::get_aabb() const {
if (!mesh.is_null())
return mesh->get_aabb();
- return Rect3();
+ return AABB();
}
PoolVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index 8e8c12a592..970a10aaf3 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -85,7 +85,7 @@ public:
void create_debug_tangents();
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
MeshInstance();
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp
index f90489f1f0..ce7b97be7f 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance.cpp
@@ -55,10 +55,10 @@ PoolVector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const {
return PoolVector<Face3>();
}
-Rect3 MultiMeshInstance::get_aabb() const {
+AABB MultiMeshInstance::get_aabb() const {
if (multimesh.is_null())
- return Rect3();
+ return AABB();
else
return multimesh->get_aabb();
}
diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h
index cd0e7b463c..9b2b1ff9a7 100644
--- a/scene/3d/multimesh_instance.h
+++ b/scene/3d/multimesh_instance.h
@@ -52,7 +52,7 @@ public:
void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
MultiMeshInstance();
~MultiMeshInstance();
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 80c706898d..2a032f5d96 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -31,9 +31,9 @@
#include "scene/resources/surface_tool.h"
#include "servers/visual_server.h"
-Rect3 Particles::get_aabb() const {
+AABB Particles::get_aabb() const {
- return Rect3();
+ return AABB();
}
PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
@@ -82,7 +82,7 @@ void Particles::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
}
-void Particles::set_visibility_aabb(const Rect3 &p_aabb) {
+void Particles::set_visibility_aabb(const AABB &p_aabb) {
visibility_aabb = p_aabb;
VS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb);
@@ -140,7 +140,7 @@ float Particles::get_randomness_ratio() const {
return randomness_ratio;
}
-Rect3 Particles::get_visibility_aabb() const {
+AABB Particles::get_visibility_aabb() const {
return visibility_aabb;
}
@@ -252,7 +252,7 @@ void Particles::restart() {
VisualServer::get_singleton()->particles_restart(particles);
}
-Rect3 Particles::capture_aabb() const {
+AABB Particles::capture_aabb() const {
return VS::get_singleton()->particles_get_current_aabb(particles);
}
@@ -335,7 +335,7 @@ void Particles::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta");
ADD_GROUP("Drawing", "");
- ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb");
+ ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates");
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,View Depth"), "set_draw_order", "get_draw_order");
ADD_GROUP("Process Material", "");
@@ -367,7 +367,7 @@ Particles::Particles() {
set_pre_process_time(0);
set_explosiveness_ratio(0);
set_randomness_ratio(0);
- set_visibility_aabb(Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8)));
+ set_visibility_aabb(AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)));
set_use_local_coordinates(true);
set_draw_passes(1);
set_draw_order(DRAW_ORDER_INDEX);
@@ -462,8 +462,6 @@ void ParticlesMaterial::finish_shaders() {
void ParticlesMaterial::_update_shader() {
- print_line("updating shader");
-
dirty_materials.remove(&element);
MaterialKey mk = _compute_key();
@@ -587,298 +585,300 @@ void ParticlesMaterial::_update_shader() {
//need a random function
code += "\n\n";
code += "float rand_from_seed(inout uint seed) {\n";
- code += " int k;\n";
- code += " int s = int(seed);\n";
- code += " if (s == 0)\n";
+ code += " int k;\n";
+ code += " int s = int(seed);\n";
+ code += " if (s == 0)\n";
code += " s = 305420679;\n";
- code += " k = s / 127773;\n";
- code += " s = 16807 * (s - k * 127773) - 2836 * k;\n";
- code += " if (s < 0)\n";
- code += " s += 2147483647;\n";
- code += " seed = uint(s);\n";
- code += " return float(seed % uint(65536))/65535.0;\n";
+ code += " k = s / 127773;\n";
+ code += " s = 16807 * (s - k * 127773) - 2836 * k;\n";
+ code += " if (s < 0)\n";
+ code += " s += 2147483647;\n";
+ code += " seed = uint(s);\n";
+ code += " return float(seed % uint(65536))/65535.0;\n";
code += "}\n";
+ code += "\n";
+
//improve seed quality
code += "uint hash(uint x) {\n";
- code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
- code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
- code += " x = (x >> uint(16)) ^ x;\n";
- code += " return x;\n";
+ code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
+ code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n";
+ code += " x = (x >> uint(16)) ^ x;\n";
+ code += " return x;\n";
code += "}\n";
- code += "void vertex() {\n\n";
code += "\n";
- code += " uint base_number=NUMBER/uint(trail_divisor);\n";
- code += " uint alt_seed=hash(base_number+uint(1)+RANDOM_SEED);\n";
- code += " float angle_rand=rand_from_seed(alt_seed);\n";
- code += " float scale_rand=rand_from_seed(alt_seed);\n";
- code += " float hue_rot_rand=rand_from_seed(alt_seed);\n";
- code += " float anim_offset_rand=rand_from_seed(alt_seed);\n";
- code += "\n";
- code += "\n";
- code += "\n";
+ code += "void vertex() {\n";
+ code += " uint base_number = NUMBER/uint(trail_divisor);\n";
+ code += " uint alt_seed = hash(base_number+uint(1)+RANDOM_SEED);\n";
+ code += " float angle_rand = rand_from_seed(alt_seed);\n";
+ code += " float scale_rand = rand_from_seed(alt_seed);\n";
+ code += " float hue_rot_rand = rand_from_seed(alt_seed);\n";
+ code += " float anim_offset_rand = rand_from_seed(alt_seed);\n";
code += "\n";
+
if (emission_shape >= EMISSION_SHAPE_POINTS) {
- code += " int point = min(emission_texture_point_count-1,int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n";
- code += " ivec2 emission_tex_size = textureSize( emission_texture_points, 0 );\n";
- code += " ivec2 emission_tex_ofs = ivec2( point % emission_tex_size.x, point / emission_tex_size.x );\n";
+ code += " int point = min(emission_texture_point_count-1,int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n";
+ code += " ivec2 emission_tex_size = textureSize( emission_texture_points, 0 );\n";
+ code += " ivec2 emission_tex_ofs = ivec2( point % emission_tex_size.x, point / emission_tex_size.x );\n";
}
- code += " if (RESTART) {\n";
+ code += " if (RESTART) {\n";
if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
- code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(0.0,0.0),0.0).r;\n";
+ code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(0.0,0.0),0.0).r;\n";
else
- code += " float tex_linear_velocity = 0.0;\n";
+ code += " float tex_linear_velocity = 0.0;\n";
if (tex_parameters[PARAM_ANGLE].is_valid())
- code += " float tex_angle = textureLod(angle_texture,vec2(0.0,0.0),0.0).r;\n";
+ code += " float tex_angle = textureLod(angle_texture,vec2(0.0,0.0),0.0).r;\n";
else
- code += " float tex_angle = 0.0;\n";
+ code += " float tex_angle = 0.0;\n";
if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
- code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(0.0,0.0),0.0).r;\n";
+ code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(0.0,0.0),0.0).r;\n";
else
- code += " float tex_anim_offset = 0.0;\n";
+ code += " float tex_anim_offset = 0.0;\n";
if (flags[FLAG_DISABLE_Z]) {
- code += " float angle1 = (rand_from_seed(alt_seed)*2.0-1.0)*spread/180.0*3.1416;\n";
- code += " vec3 rot=vec3( cos(angle1), sin(angle1),0.0 );\n";
- code += " VELOCITY=(rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n";
+ code += " float angle1 = (rand_from_seed(alt_seed)*2.0-1.0)*spread/180.0*3.1416;\n";
+ code += " vec3 rot = vec3( cos(angle1), sin(angle1),0.0 );\n";
+ code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n";
} else {
//initiate velocity spread in 3D
- code += " float angle1 = rand_from_seed(alt_seed)*spread*3.1416;\n";
- code += " float angle2 = rand_from_seed(alt_seed)*20.0*3.1416; // make it more random like\n";
- code += " vec3 rot_xz=vec3( sin(angle1), 0.0, cos(angle1) );\n";
- code += " vec3 rot = vec3( cos(angle2)*rot_xz.x,sin(angle2)*rot_xz.x, rot_xz.z);\n";
- code += " VELOCITY=(rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n";
+ code += " float angle1 = rand_from_seed(alt_seed)*spread*3.1416;\n";
+ code += " float angle2 = rand_from_seed(alt_seed)*20.0*3.1416; // make it more random like\n";
+ code += " vec3 rot_xz = vec3( sin(angle1), 0.0, cos(angle1) );\n";
+ code += " vec3 rot = vec3( cos(angle2)*rot_xz.x,sin(angle2)*rot_xz.x, rot_xz.z);\n";
+ code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n";
}
- code += " float base_angle=(initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n";
- code += " CUSTOM.x=base_angle*3.1416/180.0;\n"; //angle
- code += " CUSTOM.y=0.0;\n"; //phase
- code += " CUSTOM.z=(anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random);\n"; //animation offset (0-1)
+ code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n";
+ code += " CUSTOM.x = base_angle*3.1416/180.0;\n"; //angle
+ code += " CUSTOM.y = 0.0;\n"; //phase
+ code += " CUSTOM.z = (anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random);\n"; //animation offset (0-1)
switch (emission_shape) {
case EMISSION_SHAPE_POINT: {
//do none
} break;
case EMISSION_SHAPE_SPHERE: {
- code += " TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0 ))*emission_sphere_radius;\n";
+ code += " TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0 ))*emission_sphere_radius;\n";
} break;
case EMISSION_SHAPE_BOX: {
- code += " TRANSFORM[3].xyz = vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0)*emission_box_extents;\n";
+ code += " TRANSFORM[3].xyz = vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0-1.0, rand_from_seed(alt_seed) * 2.0-1.0)*emission_box_extents;\n";
} break;
case EMISSION_SHAPE_POINTS:
case EMISSION_SHAPE_DIRECTED_POINTS: {
- code += " TRANSFORM[3].xyz = texelFetch(emission_texture_points, emission_tex_ofs,0).xyz;\n";
+ code += " TRANSFORM[3].xyz = texelFetch(emission_texture_points, emission_tex_ofs,0).xyz;\n";
if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) {
if (flags[FLAG_DISABLE_Z]) {
- code += " mat2 rotm;";
- code += " rotm[0]=texelFetch(emission_texture_normal, emission_tex_ofs,0).xy;\n";
- code += " rotm[1]=rotm[0].yx * vec2(1.0,-1.0);\n";
- code += " VELOCITY.xy = rotm * VELOCITY.xy;\n";
+ code += " mat2 rotm;";
+ code += " rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs,0).xy;\n";
+ code += " rotm[1] = rotm[0].yx * vec2(1.0,-1.0);\n";
+ code += " VELOCITY.xy = rotm * VELOCITY.xy;\n";
} else {
- code += " vec3 normal = texelFetch(emission_texture_normal, emission_tex_ofs,0).xyz;\n";
- code += " vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0, 1.0, 0.0);\n";
- code += " vec3 tangent = normalize(cross(v0, normal));\n";
- code += " vec3 bitangent = normalize(cross(tangent, normal));\n";
- code += " VELOCITY = mat3(tangent,bitangent,normal) * VELOCITY;\n";
+ code += " vec3 normal = texelFetch(emission_texture_normal, emission_tex_ofs,0).xyz;\n";
+ code += " vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0, 1.0, 0.0);\n";
+ code += " vec3 tangent = normalize(cross(v0, normal));\n";
+ code += " vec3 bitangent = normalize(cross(tangent, normal));\n";
+ code += " VELOCITY = mat3(tangent,bitangent,normal) * VELOCITY;\n";
}
}
} break;
}
- code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY,0.0)).xyz;\n";
- code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n";
+ code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY,0.0)).xyz;\n";
+ code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n";
if (flags[FLAG_DISABLE_Z]) {
- code += " VELOCITY.z=0.0;\n";
- code += " TRANSFORM[3].z=0.0;\n";
+ code += " VELOCITY.z = 0.0;\n";
+ code += " TRANSFORM[3].z = 0.0;\n";
}
- code += " } else {\n";
+ code += " } else {\n";
- code += " CUSTOM.y+=DELTA/LIFETIME;\n";
+ code += " CUSTOM.y += DELTA/LIFETIME;\n";
if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
- code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_linear_velocity = textureLod(linear_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_linear_velocity = 0.0;\n";
+ code += " float tex_linear_velocity = 0.0;\n";
if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid())
- code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_orbit_velocity = 0.0;\n";
+ code += " float tex_orbit_velocity = 0.0;\n";
if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid())
- code += " float tex_angular_velocity = textureLod(angular_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_angular_velocity = textureLod(angular_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_angular_velocity = 0.0;\n";
+ code += " float tex_angular_velocity = 0.0;\n";
if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid())
- code += " float tex_linear_accel = textureLod(linear_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_linear_accel = textureLod(linear_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_linear_accel = 0.0;\n";
+ code += " float tex_linear_accel = 0.0;\n";
if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid())
- code += " float tex_radial_accel = textureLod(radial_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_radial_accel = textureLod(radial_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_radial_accel = 0.0;\n";
+ code += " float tex_radial_accel = 0.0;\n";
if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid())
- code += " float tex_tangent_accel = textureLod(tangent_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_tangent_accel = textureLod(tangent_accel_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_tangent_accel = 0.0;\n";
+ code += " float tex_tangent_accel = 0.0;\n";
if (tex_parameters[PARAM_DAMPING].is_valid())
- code += " float tex_damping = textureLod(damping_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_damping = textureLod(damping_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_damping = 0.0;\n";
+ code += " float tex_damping = 0.0;\n";
if (tex_parameters[PARAM_ANGLE].is_valid())
- code += " float tex_angle = textureLod(angle_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_angle = textureLod(angle_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_angle = 0.0;\n";
+ code += " float tex_angle = 0.0;\n";
if (tex_parameters[PARAM_ANIM_SPEED].is_valid())
- code += " float tex_anim_speed = textureLod(anim_speed_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_anim_speed = textureLod(anim_speed_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_anim_speed = 0.0;\n";
+ code += " float tex_anim_speed = 0.0;\n";
if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
- code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_anim_offset = textureLod(anim_offset_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_anim_offset = 0.0;\n";
+ code += " float tex_anim_offset = 0.0;\n";
- code += " vec3 force = gravity; \n";
- code += " vec3 pos = TRANSFORM[3].xyz; \n";
+ code += " vec3 force = gravity; \n";
+ code += " vec3 pos = TRANSFORM[3].xyz; \n";
if (flags[FLAG_DISABLE_Z]) {
- code += " pos.z=0.0; \n";
+ code += " pos.z = 0.0; \n";
}
- code += " //apply linear acceleration\n";
- code += " force+= length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random) : vec3(0.0);\n";
- code += " //apply radial acceleration\n";
- code += " vec3 org = vec3(0.0);\n";
- code += " // if (!p_system->local_coordinates)\n";
- code += " //org=p_transform.origin;\n";
- code += " vec3 diff = pos-org;\n";
- code += " force+=length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n";
- code += " //apply tangential acceleration;\n";
+ code += " //apply linear acceleration\n";
+ code += " force += length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random) : vec3(0.0);\n";
+ code += " //apply radial acceleration\n";
+ code += " vec3 org = vec3(0.0);\n";
+ code += " vec3 diff = pos-org;\n";
+ code += " force += length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n";
+ code += " //apply tangential acceleration;\n";
if (flags[FLAG_DISABLE_Z]) {
- code += " force+=length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n";
+ code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n";
} else {
- code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n";
- code += " force+=length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n";
+ code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n";
+ code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n";
}
- code += " //apply attractor forces\n";
- code += " VELOCITY+=force * DELTA;\n";
+ code += " //apply attractor forces\n";
+ code += " VELOCITY += force * DELTA;\n";
if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
- code += " VELOCITY=normalize(VELOCITY)*tex_linear_velocity;\n";
+ code += " VELOCITY = normalize(VELOCITY)*tex_linear_velocity;\n";
}
- code += " if (damping+tex_damping>0.0) {\n";
- code += " \n";
- code += " float v = length(VELOCITY);\n";
- code += " float damp = (damping+tex_damping)*mix(1.0,rand_from_seed(alt_seed),damping_random);\n";
- code += " v -= damp * DELTA;\n";
- code += " if (v<0.0) {\n";
- code += " VELOCITY=vec3(0.0);\n";
- code += " } else {\n";
- code += " VELOCITY=normalize(VELOCITY) * v;\n";
- code += " }\n";
- code += " }\n";
- code += " float base_angle=(initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n";
- code += " base_angle+=CUSTOM.y*LIFETIME*(angular_velocity+tex_angular_velocity)*mix(1.0,rand_from_seed(alt_seed)*2.0-1.0,angular_velocity_random);\n";
- code += " CUSTOM.x=base_angle*3.1416/180.0;\n"; //angle
- code += " CUSTOM.z=(anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random)+CUSTOM.y*(anim_speed+tex_anim_speed)*mix(1.0,rand_from_seed(alt_seed),anim_speed_random);\n"; //angle
+ code += " if (damping + tex_damping > 0.0) {\n";
+ code += " \n";
+ code += " float v = length(VELOCITY);\n";
+ code += " float damp = (damping+tex_damping)*mix(1.0,rand_from_seed(alt_seed),damping_random);\n";
+ code += " v -= damp * DELTA;\n";
+ code += " if (v < 0.0) {\n";
+ code += " VELOCITY = vec3(0.0);\n";
+ code += " } else {\n";
+ code += " VELOCITY = normalize(VELOCITY) * v;\n";
+ code += " }\n";
+ code += " }\n";
+ code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n";
+ code += " base_angle += CUSTOM.y*LIFETIME*(angular_velocity+tex_angular_velocity)*mix(1.0,rand_from_seed(alt_seed)*2.0-1.0,angular_velocity_random);\n";
+ code += " CUSTOM.x = base_angle*3.1416/180.0;\n"; //angle
+ code += " CUSTOM.z = (anim_offset+tex_anim_offset)*mix(1.0,anim_offset_rand,anim_offset_random)+CUSTOM.y*(anim_speed+tex_anim_speed)*mix(1.0,rand_from_seed(alt_seed),anim_speed_random);\n"; //angle
if (flags[FLAG_ANIM_LOOP]) {
- code += " CUSTOM.z=mod(CUSTOM.z,1.0);\n"; //loop
+ code += " CUSTOM.z = mod(CUSTOM.z,1.0);\n"; //loop
} else {
- code += " CUSTOM.z=clamp(CUSTOM.z,0.0,1.0);\n"; //0 to 1 only
+ code += " CUSTOM.z = clamp(CUSTOM.z,0.0,1.0);\n"; //0 to 1 only
}
- code += " }\n";
+ code += " }\n";
//apply color
//apply hue rotation
if (tex_parameters[PARAM_SCALE].is_valid())
- code += " float tex_scale = textureLod(scale_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_scale = textureLod(scale_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_scale = 1.0;\n";
+ code += " float tex_scale = 1.0;\n";
if (tex_parameters[PARAM_HUE_VARIATION].is_valid())
- code += " float tex_hue_variation = textureLod(hue_variation_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
+ code += " float tex_hue_variation = textureLod(hue_variation_texture,vec2(CUSTOM.y,0.0),0.0).r;\n";
else
- code += " float tex_hue_variation = 0.0;\n";
-
- code += " float hue_rot_angle = (hue_variation+tex_hue_variation)*3.1416*2.0*mix(1.0,hue_rot_rand*2.0-1.0,hue_variation_random);\n";
- code += " float hue_rot_c = cos(hue_rot_angle);\n";
- code += " float hue_rot_s = sin(hue_rot_angle);\n";
- code += " mat4 hue_rot_mat = mat4( vec4(0.299, 0.587, 0.114, 0.0),\n";
- code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
- code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
- code += " vec4(0.000, 0.000, 0.000, 1.0)) +\n";
- code += " \n";
- code += " mat4( vec4(0.701, -0.587, -0.114, 0.0),\n";
- code += " vec4(-0.299, 0.413, -0.114, 0.0),\n";
- code += " vec4(-0.300, -0.588, 0.886, 0.0),\n";
- code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_c +\n";
- code += "\n";
- code += " mat4( vec4(0.168, 0.330, -0.497, 0.0),\n";
- code += " vec4(-0.328, 0.035, 0.292, 0.0),\n";
- code += " vec4(1.250, -1.050, -0.203, 0.0),\n";
- code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;\n";
+ code += " float tex_hue_variation = 0.0;\n";
+
+ code += " float hue_rot_angle = (hue_variation+tex_hue_variation)*3.1416*2.0*mix(1.0,hue_rot_rand*2.0-1.0,hue_variation_random);\n";
+ code += " float hue_rot_c = cos(hue_rot_angle);\n";
+ code += " float hue_rot_s = sin(hue_rot_angle);\n";
+ code += " mat4 hue_rot_mat = mat4( vec4(0.299, 0.587, 0.114, 0.0),\n";
+ code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
+ code += " vec4(0.299, 0.587, 0.114, 0.0),\n";
+ code += " vec4(0.000, 0.000, 0.000, 1.0)) +\n";
+ code += " mat4( vec4(0.701, -0.587, -0.114, 0.0),\n";
+ code += " vec4(-0.299, 0.413, -0.114, 0.0),\n";
+ code += " vec4(-0.300, -0.588, 0.886, 0.0),\n";
+ code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_c +\n";
+ code += " mat4( vec4(0.168, 0.330, -0.497, 0.0),\n";
+ code += " vec4(-0.328, 0.035, 0.292, 0.0),\n";
+ code += " vec4(1.250, -1.050, -0.203, 0.0),\n";
+ code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;\n";
if (color_ramp.is_valid()) {
- code += " COLOR = textureLod(color_ramp,vec2(CUSTOM.y,0.0),0.0) * hue_rot_mat;\n";
+ code += " COLOR = textureLod(color_ramp,vec2(CUSTOM.y,0.0),0.0) * hue_rot_mat;\n";
} else {
- code += " COLOR = color_value * hue_rot_mat;\n";
+ code += " COLOR = color_value * hue_rot_mat;\n";
}
if (emission_color_texture.is_valid() && emission_shape >= EMISSION_SHAPE_POINTS) {
- code += " COLOR*= texelFetch(emission_texture_color,emission_tex_ofs,0);\n";
+ code += " COLOR*= texelFetch(emission_texture_color,emission_tex_ofs,0);\n";
}
if (trail_color_modifier.is_valid()) {
- code += "if (trail_divisor>1) { COLOR*=textureLod(trail_color_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0); }\n";
+ code += " if (trail_divisor > 1) { COLOR *= textureLod(trail_color_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0); }\n";
}
code += "\n";
if (flags[FLAG_DISABLE_Z]) {
- code += " TRANSFORM[0]=vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[1]=vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[2]=vec4(0.0,0.0,1.0,0.0);\n";
+ if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
+ code += " if (length(VELOCITY) > 0.0) { TRANSFORM[1].xyz = normalize(VELOCITY); } else { TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz); }\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(TRANSFORM[1].xyz,TRANSFORM[2].xyz));\n";
+ code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ } else {
+ code += " TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n";
+ code += " TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n";
+ code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ }
} else {
//orient particle Y towards velocity
if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
- code += " if (length(VELOCITY)>0.0) {TRANSFORM[1].xyz=normalize(VELOCITY);} else {TRANSFORM[1].xyz=normalize(TRANSFORM[1].xyz);}\n";
- code += " if (TRANSFORM[1].xyz==normalize(TRANSFORM[0].xyz)) {\n";
- code += "\tTRANSFORM[0].xyz=normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n";
- code += "\tTRANSFORM[2].xyz=normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n";
- code += " } else {\n";
- code += "\tTRANSFORM[2].xyz=normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n";
- code += "\tTRANSFORM[0].xyz=normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n";
- code += " }\n";
+ code += " if (length(VELOCITY) > 0.0) { TRANSFORM[1].xyz = normalize(VELOCITY); } else { TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz); }\n";
+ code += " if (TRANSFORM[1].xyz == normalize(TRANSFORM[0].xyz)) {\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n";
+ code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n";
+ code += " } else {\n";
+ code += " TRANSFORM[2].xyz = normalize(cross(normalize(TRANSFORM[0].xyz),normalize(TRANSFORM[1].xyz)));\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(normalize(TRANSFORM[1].xyz),normalize(TRANSFORM[2].xyz)));\n";
+ code += " }\n";
} else {
- code += "\tTRANSFORM[0].xyz=normalize(TRANSFORM[0].xyz);\n";
- code += "\tTRANSFORM[1].xyz=normalize(TRANSFORM[1].xyz);\n";
- code += "\tTRANSFORM[2].xyz=normalize(TRANSFORM[2].xyz);\n";
+ code += " TRANSFORM[0].xyz = normalize(TRANSFORM[0].xyz);\n";
+ code += " TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);\n";
+ code += " TRANSFORM[2].xyz = normalize(TRANSFORM[2].xyz);\n";
}
//turn particle by rotation in Y
if (flags[FLAG_ROTATE_Y]) {
- code += "\tTRANSFORM = TRANSFORM * mat4( vec4(cos(CUSTOM.x),0.0,-sin(CUSTOM.x),0.0), vec4(0.0,1.0,0.0,0.0),vec4(sin(CUSTOM.x),0.0,cos(CUSTOM.x),0.0),vec4(0.0,0.0,0.0,1.0));\n";
+ code += " TRANSFORM = TRANSFORM * mat4( vec4(cos(CUSTOM.x),0.0,-sin(CUSTOM.x),0.0), vec4(0.0,1.0,0.0,0.0),vec4(sin(CUSTOM.x),0.0,cos(CUSTOM.x),0.0),vec4(0.0,0.0,0.0,1.0));\n";
}
}
//scale by scale
- code += " float base_scale=mix(scale*tex_scale,1.0,scale_random*scale_rand);\n";
+ code += " float base_scale = mix(scale*tex_scale,1.0,scale_random*scale_rand);\n";
if (trail_size_modifier.is_valid()) {
- code += "if (trail_divisor>1) { base_scale*=textureLod(trail_size_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0).r; } \n";
+ code += " if (trail_divisor > 1) { base_scale *= textureLod(trail_size_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0).r; } \n";
}
- code += " TRANSFORM[0].xyz*=base_scale;\n";
- code += " TRANSFORM[1].xyz*=base_scale;\n";
- code += " TRANSFORM[2].xyz*=base_scale;\n";
+ code += " TRANSFORM[0].xyz *= base_scale;\n";
+ code += " TRANSFORM[1].xyz *= base_scale;\n";
+ code += " TRANSFORM[2].xyz *= base_scale;\n";
if (flags[FLAG_DISABLE_Z]) {
- code += " VELOCITY.z=0.0;\n";
- code += " TRANSFORM[3].z=0.0;\n";
+ code += " VELOCITY.z = 0.0;\n";
+ code += " TRANSFORM[3].z = 0.0;\n";
}
code += "}\n";
code += "\n";
@@ -913,9 +913,7 @@ void ParticlesMaterial::_queue_shader_change() {
if (material_mutex)
material_mutex->lock();
- print_line("queuing change");
if (!element.in_list()) {
- print_line("not in list, adding");
dirty_materials.add(&element);
}
@@ -1329,6 +1327,12 @@ Vector3 ParticlesMaterial::get_gravity() const {
return gravity;
}
+RID ParticlesMaterial::get_shader_rid() const {
+
+ ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
+ return shader_map[current_key].shader;
+}
+
void ParticlesMaterial::_validate_property(PropertyInfo &property) const {
if (property.name == "color" && color_ramp.is_valid()) {
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index 2c109d6ec8..30080360bb 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -65,7 +65,7 @@ private:
float explosiveness_ratio;
float randomness_ratio;
float speed_scale;
- Rect3 visibility_aabb;
+ AABB visibility_aabb;
bool local_coords;
int fixed_fps;
bool fractional_delta;
@@ -82,7 +82,7 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
- Rect3 get_aabb() const;
+ AABB get_aabb() const;
PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_emitting(bool p_emitting);
@@ -92,7 +92,7 @@ public:
void set_pre_process_time(float p_time);
void set_explosiveness_ratio(float p_ratio);
void set_randomness_ratio(float p_ratio);
- void set_visibility_aabb(const Rect3 &p_aabb);
+ void set_visibility_aabb(const AABB &p_aabb);
void set_use_local_coordinates(bool p_enable);
void set_process_material(const Ref<Material> &p_material);
void set_speed_scale(float p_scale);
@@ -104,7 +104,7 @@ public:
float get_pre_process_time() const;
float get_explosiveness_ratio() const;
float get_randomness_ratio() const;
- Rect3 get_visibility_aabb() const;
+ AABB get_visibility_aabb() const;
bool get_use_local_coordinates() const;
Ref<Material> get_process_material() const;
float get_speed_scale() const;
@@ -128,7 +128,7 @@ public:
void restart();
- Rect3 capture_aabb() const;
+ AABB capture_aabb() const;
Particles();
~Particles();
};
@@ -388,6 +388,8 @@ public:
static void finish_shaders();
static void flush_changes();
+ RID get_shader_rid() const;
+
ParticlesMaterial();
~ParticlesMaterial();
};
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index 60245fe6ce..65f20210e1 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -85,9 +85,15 @@ void PathFollow::_update_transform() {
if (!c.is_valid())
return;
+ if (delta_offset == 0) {
+ return;
+ }
+
float o = offset;
- if (loop)
+
+ if (loop) {
o = Math::fposmod(o, c->get_baked_length());
+ }
Vector3 pos = c->interpolate_baked(o, cubic);
Transform t = get_transform();
@@ -101,14 +107,14 @@ void PathFollow::_update_transform() {
// see C. Dougan, The Parallel Transport Frame, Game Programming Gems 2 for example
// for a discussion about why not Frenet frame.
- Vector3 t_prev = pos - c->interpolate_baked(o - lookahead, cubic);
- Vector3 t_cur = c->interpolate_baked(o + lookahead, cubic) - pos;
+ Vector3 t_prev = (pos - c->interpolate_baked(o - delta_offset, cubic)).normalized();
+ Vector3 t_cur = (c->interpolate_baked(o + delta_offset, cubic) - pos).normalized();
Vector3 axis = t_prev.cross(t_cur);
- float dot = t_prev.normalized().dot(t_cur.normalized());
+ float dot = t_prev.dot(t_cur);
float angle = Math::acos(CLAMP(dot, -1, 1));
- if (axis.length() > CMP_EPSILON && angle > CMP_EPSILON) {
+ if (likely(Math::abs(angle) > CMP_EPSILON)) {
if (rotation_mode == ROTATION_Y) {
// assuming we're referring to global Y-axis. is this correct?
axis.x = 0;
@@ -116,27 +122,31 @@ void PathFollow::_update_transform() {
} else if (rotation_mode == ROTATION_XY) {
axis.z = 0;
} else if (rotation_mode == ROTATION_XYZ) {
- // all components are OK
+ // all components are allowed
}
- t.rotate_basis(axis.normalized(), angle);
+ if (likely(axis.length() > CMP_EPSILON)) {
+ t.rotate_basis(axis.normalized(), angle);
+ }
}
// do the additional tilting
float tilt_angle = c->interpolate_baked_tilt(o);
- Vector3 tilt_axis = t_cur; // is this correct??
+ Vector3 tilt_axis = t_cur; // not sure what tilt is supposed to do, is this correct??
- if (tilt_axis.length() > CMP_EPSILON && tilt_angle > CMP_EPSILON) {
+ if (likely(Math::abs(tilt_angle) > CMP_EPSILON)) {
if (rotation_mode == ROTATION_Y) {
tilt_axis.x = 0;
tilt_axis.z = 0;
} else if (rotation_mode == ROTATION_XY) {
tilt_axis.z = 0;
} else if (rotation_mode == ROTATION_XYZ) {
- // all components are OK
+ // all components are allowed
}
- t.rotate_basis(tilt_axis.normalized(), tilt_angle);
+ if (likely(tilt_axis.length() > CMP_EPSILON)) {
+ t.rotate_basis(tilt_axis.normalized(), tilt_angle);
+ }
}
t.translate(pos_offset);
@@ -195,8 +205,6 @@ bool PathFollow::_set(const StringName &p_name, const Variant &p_value) {
set_cubic_interpolation(p_value);
} else if (String(p_name) == "loop") {
set_loop(p_value);
- } else if (String(p_name) == "lookahead") {
- set_lookahead(p_value);
} else
return false;
@@ -219,8 +227,6 @@ bool PathFollow::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = cubic;
} else if (String(p_name) == "loop") {
r_ret = loop;
- } else if (String(p_name) == "lookahead") {
- r_ret = lookahead;
} else
return false;
@@ -238,7 +244,6 @@ void PathFollow::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ"));
p_list->push_back(PropertyInfo(Variant::BOOL, "cubic_interp"));
p_list->push_back(PropertyInfo(Variant::BOOL, "loop"));
- p_list->push_back(PropertyInfo(Variant::REAL, "lookahead", PROPERTY_HINT_RANGE, "0.001,1024.0,0.001"));
}
void PathFollow::_bind_methods() {
@@ -271,8 +276,9 @@ void PathFollow::_bind_methods() {
}
void PathFollow::set_offset(float p_offset) {
-
+ delta_offset = p_offset - offset;
offset = p_offset;
+
if (path)
_update_transform();
_change_notify("offset");
@@ -322,16 +328,6 @@ float PathFollow::get_unit_offset() const {
return 0;
}
-void PathFollow::set_lookahead(float p_lookahead) {
-
- lookahead = p_lookahead;
-}
-
-float PathFollow::get_lookahead() const {
-
- return lookahead;
-}
-
void PathFollow::set_rotation_mode(RotationMode p_rotation_mode) {
rotation_mode = p_rotation_mode;
@@ -356,11 +352,11 @@ bool PathFollow::has_loop() const {
PathFollow::PathFollow() {
offset = 0;
+ delta_offset = 0;
h_offset = 0;
v_offset = 0;
path = NULL;
rotation_mode = ROTATION_XYZ;
cubic = true;
loop = true;
- lookahead = 0.1;
}
diff --git a/scene/3d/path.h b/scene/3d/path.h
index 0f9a169f72..52760e0c75 100644
--- a/scene/3d/path.h
+++ b/scene/3d/path.h
@@ -67,10 +67,10 @@ public:
private:
Path *path;
+ real_t delta_offset; // change in offset since last _update_transform
real_t offset;
real_t h_offset;
real_t v_offset;
- real_t lookahead;
bool cubic;
bool loop;
RotationMode rotation_mode;
@@ -98,9 +98,6 @@ public:
void set_unit_offset(float p_unit_offset);
float get_unit_offset() const;
- void set_lookahead(float p_lookahead);
- float get_lookahead() const;
-
void set_loop(bool p_loop);
bool has_loop() const;
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index d7fdf94d40..4e06b272e2 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -870,10 +870,10 @@ void RigidBody::_bind_methods() {
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- BIND_ENUM_CONSTANT(MODE_STATIC);
- BIND_ENUM_CONSTANT(MODE_KINEMATIC);
BIND_ENUM_CONSTANT(MODE_RIGID);
+ BIND_ENUM_CONSTANT(MODE_STATIC);
BIND_ENUM_CONSTANT(MODE_CHARACTER);
+ BIND_ENUM_CONSTANT(MODE_KINEMATIC);
BIND_ENUM_CONSTANT(AXIS_LOCK_DISABLED);
BIND_ENUM_CONSTANT(AXIS_LOCK_X);
@@ -938,7 +938,7 @@ bool KinematicBody::move_and_collide(const Vector3 &p_motion, Collision &r_colli
Transform gt = get_global_transform();
PhysicsServer::MotionResult result;
- bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, margin, &result);
+ bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, &result);
if (colliding) {
r_collision.collider_metadata = result.collider_metadata;
@@ -988,12 +988,15 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
on_floor = true;
floor_velocity = collision.collider_vel;
- /*if (collision.travel.length() < 0.01 && ABS((lv.x - floor_velocity.x)) < p_slope_stop_min_velocity) {
+ Vector3 rel_v = lv - floor_velocity;
+ Vector3 hv = rel_v - p_floor_direction * p_floor_direction.dot(rel_v);
+
+ if (collision.travel.length() < 0.05 && hv.length() < p_slope_stop_min_velocity) {
Transform gt = get_global_transform();
- gt.elements[2] -= collision.travel;
+ gt.origin -= collision.travel;
set_global_transform(gt);
- return Vector3();
- }*/
+ return floor_velocity - p_floor_direction * p_floor_direction.dot(floor_velocity);
+ }
} else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle)) { //ceiling
on_ceiling = true;
} else {
@@ -1041,12 +1044,13 @@ bool KinematicBody::test_move(const Transform &p_from, const Vector3 &p_motion)
ERR_FAIL_COND_V(!is_inside_tree(), false);
- return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, margin);
+ return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion);
}
void KinematicBody::set_safe_margin(float p_margin) {
margin = p_margin;
+ PhysicsServer::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin);
}
float KinematicBody::get_safe_margin() const {
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index aa127ab79f..1d779d31fe 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -32,13 +32,8 @@
void Joint::_update_joint(bool p_only_free) {
if (joint.is_valid()) {
- if (ba.is_valid() && bb.is_valid()) {
-
- if (exclude_from_collision)
- PhysicsServer::get_singleton()->body_add_collision_exception(ba, bb);
- else
- PhysicsServer::get_singleton()->body_remove_collision_exception(ba, bb);
- }
+ if (ba.is_valid() && bb.is_valid())
+ PhysicsServer::get_singleton()->body_remove_collision_exception(ba, bb);
PhysicsServer::get_singleton()->free(joint);
joint = RID();
@@ -52,33 +47,31 @@ void Joint::_update_joint(bool p_only_free) {
Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
- if (!node_a && !node_b)
+ if (!node_a || !node_b)
return;
PhysicsBody *body_a = Object::cast_to<PhysicsBody>(node_a);
PhysicsBody *body_b = Object::cast_to<PhysicsBody>(node_b);
- if (!body_a && !body_b)
+ if (!body_a || !body_b)
return;
if (!body_a) {
SWAP(body_a, body_b);
- } else if (body_b) {
- //add a collision exception between both
- PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
}
joint = _configure_joint(body_a, body_b);
- if (joint.is_valid())
- PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
+ if (!joint.is_valid())
+ return;
+
+ PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
- if (body_b && joint.is_valid()) {
+ ba = body_a->get_rid();
+ bb = body_b->get_rid();
- ba = body_a->get_rid();
- bb = body_b->get_rid();
+ if (exclude_from_collision)
PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
- }
}
void Joint::set_node_a(const NodePath &p_node_a) {
@@ -129,8 +122,6 @@ void Joint::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
if (joint.is_valid()) {
_update_joint(true);
- //PhysicsServer::get_singleton()->free(joint);
- joint = RID();
}
} break;
}
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 6c14f7dbc9..4fde29aab9 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -98,7 +98,7 @@ void Portal::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "connect_range", PROPERTY_HINT_RANGE, "0.1,4096,0.01"));
}
-Rect3 Portal::get_aabb() const {
+AABB Portal::get_aabb() const {
return aabb;
}
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 6de3df8553..4ea208a718 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -53,7 +53,7 @@ class Portal : public VisualInstance {
Color disabled_color;
float connect_range;
- Rect3 aabb;
+ AABB aabb;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -63,7 +63,7 @@ protected:
static void _bind_methods();
public:
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_enabled(bool p_enabled);
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index df6764ee1a..9f61cc64ea 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -48,14 +48,14 @@ Vector3 RayCast::get_cast_to() const {
return cast_to;
}
-void RayCast::set_collision_layer(uint32_t p_layer) {
+void RayCast::set_collision_mask(uint32_t p_mask) {
- collision_layer = p_layer;
+ collision_mask = p_mask;
}
-uint32_t RayCast::get_collision_layer() const {
+uint32_t RayCast::get_collision_mask() const {
- return collision_layer;
+ return collision_mask;
}
void RayCast::set_type_mask(uint32_t p_mask) {
@@ -63,6 +63,21 @@ void RayCast::set_type_mask(uint32_t p_mask) {
type_mask = p_mask;
}
+void RayCast::set_collision_mask_bit(int p_bit, bool p_value) {
+
+ uint32_t mask = get_collision_mask();
+ if (p_value)
+ mask |= 1 << p_bit;
+ else
+ mask &= ~(1 << p_bit);
+ set_collision_mask(mask);
+}
+
+bool RayCast::get_collision_mask_bit(int p_bit) const {
+
+ return get_collision_mask() & (1 << p_bit);
+}
+
uint32_t RayCast::get_type_mask() const {
return type_mask;
@@ -172,7 +187,7 @@ void RayCast::_update_raycast_state() {
PhysicsDirectSpaceState::RayResult rr;
- if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_layer, type_mask)) {
+ if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, type_mask)) {
collided = true;
against = rr.collider_id;
@@ -245,15 +260,18 @@ void RayCast::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear_exceptions"), &RayCast::clear_exceptions);
- ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &RayCast::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &RayCast::get_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &RayCast::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &RayCast::get_collision_mask_bit);
ClassDB::bind_method(D_METHOD("set_type_mask", "mask"), &RayCast::set_type_mask);
ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast::get_type_mask);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cast_to"), "set_cast_to", "get_cast_to");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
ADD_PROPERTY(PropertyInfo(Variant::INT, "type_mask", PROPERTY_HINT_FLAGS, "Static,Kinematic,Rigid,Character,Area"), "set_type_mask", "get_type_mask");
}
@@ -325,7 +343,7 @@ RayCast::RayCast() {
against = 0;
collided = false;
against_shape = 0;
- collision_layer = 1;
+ collision_mask = 1;
type_mask = PhysicsDirectSpaceState::TYPE_MASK_COLLISION;
cast_to = Vector3(0, -1, 0);
debug_shape = NULL;
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index fd566cd343..cac1596264 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -47,7 +47,7 @@ class RayCast : public Spatial {
Set<RID> exclude;
- uint32_t collision_layer;
+ uint32_t collision_mask;
uint32_t type_mask;
Node *debug_shape;
@@ -69,8 +69,11 @@ public:
void set_cast_to(const Vector3 &p_point);
Vector3 get_cast_to() const;
- void set_collision_layer(uint32_t p_layer);
- uint32_t get_collision_layer() const;
+ void set_collision_mask(uint32_t p_mask);
+ uint32_t get_collision_mask() const;
+
+ void set_collision_mask_bit(int p_bit, bool p_value);
+ bool get_collision_mask_bit(int p_bit) const;
void set_type_mask(uint32_t p_mask);
uint32_t get_type_mask() const;
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 46b105cd21..0e575ec152 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -178,9 +178,9 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
return update_mode;
}
-Rect3 ReflectionProbe::get_aabb() const {
+AABB ReflectionProbe::get_aabb() const {
- Rect3 aabb;
+ AABB aabb;
aabb.position = -origin_offset;
aabb.size = origin_offset + extents;
return aabb;
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
index 7c328a8f16..26f17fdcf9 100644
--- a/scene/3d/reflection_probe.h
+++ b/scene/3d/reflection_probe.h
@@ -101,7 +101,7 @@ public:
void set_update_mode(UpdateMode p_mode);
UpdateMode get_update_mode() const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
ReflectionProbe();
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 439b6bfdf8..47a7b8bfb9 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -66,12 +66,12 @@ void Room::_notification(int p_what) {
}
}
-Rect3 Room::get_aabb() const {
+AABB Room::get_aabb() const {
if (room.is_null())
- return Rect3();
+ return AABB();
- return Rect3();
+ return AABB();
}
PoolVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index b9a64b6670..3069ea2eba 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -71,7 +71,7 @@ public:
NOTIFICATION_AREA_CHANGED = 60
};
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_room(const Ref<RoomBounds> &p_room);
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 0dfd80ca90..588aa2881a 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -233,7 +233,7 @@ void Spatial::set_transform(const Transform &p_transform) {
data.dirty |= DIRTY_VECTORS;
_change_notify("translation");
_change_notify("rotation");
- _change_notify("rotation_deg");
+ _change_notify("rotation_degrees");
_change_notify("scale");
_propagate_transform_changed(this);
if (data.notify_local_transform) {
@@ -327,17 +327,11 @@ void Spatial::set_rotation(const Vector3 &p_euler_rad) {
}
}
-void Spatial::set_rotation_in_degrees(const Vector3 &p_euler_deg) {
+void Spatial::set_rotation_degrees(const Vector3 &p_euler_deg) {
set_rotation(p_euler_deg * Math_PI / 180.0);
}
-void Spatial::_set_rotation_deg(const Vector3 &p_euler_deg) {
-
- WARN_PRINT("Deprecated method Spatial._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted.");
- set_rotation_in_degrees(p_euler_deg);
-}
-
void Spatial::set_scale(const Vector3 &p_scale) {
if (data.dirty & DIRTY_VECTORS) {
@@ -370,19 +364,11 @@ Vector3 Spatial::get_rotation() const {
return data.rotation;
}
-Vector3 Spatial::get_rotation_in_degrees() const {
+Vector3 Spatial::get_rotation_degrees() const {
return get_rotation() * 180.0 / Math_PI;
}
-// Kept for compatibility after rename to set_rotd.
-// Could be removed after a couple releases.
-Vector3 Spatial::_get_rotation_deg() const {
-
- WARN_PRINT("Deprecated method Spatial._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted.");
- return get_rotation_in_degrees();
-}
-
Vector3 Spatial::get_scale() const {
if (data.dirty & DIRTY_VECTORS) {
@@ -691,10 +677,10 @@ void Spatial::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_transform"), &Spatial::get_transform);
ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Spatial::set_translation);
ClassDB::bind_method(D_METHOD("get_translation"), &Spatial::get_translation);
- ClassDB::bind_method(D_METHOD("set_rotation", "rotation_rad"), &Spatial::set_rotation);
+ ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Spatial::set_rotation);
ClassDB::bind_method(D_METHOD("get_rotation"), &Spatial::get_rotation);
- ClassDB::bind_method(D_METHOD("set_rotation_deg", "rotation_deg"), &Spatial::set_rotation_in_degrees);
- ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Spatial::get_rotation_in_degrees);
+ ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Spatial::set_rotation_degrees);
+ ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Spatial::get_rotation_degrees);
ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Spatial::set_scale);
ClassDB::bind_method(D_METHOD("get_scale"), &Spatial::get_scale);
ClassDB::bind_method(D_METHOD("set_global_transform", "global"), &Spatial::set_global_transform);
@@ -705,10 +691,6 @@ void Spatial::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel);
ClassDB::bind_method(D_METHOD("get_world"), &Spatial::get_world);
- // TODO: Obsolete those two methods (old name) properly (GH-4397)
- ClassDB::bind_method(D_METHOD("_set_rotation_deg", "rotation_deg"), &Spatial::_set_rotation_deg);
- ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Spatial::_get_rotation_deg);
-
#ifdef TOOLS_ENABLED
ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo);
#endif
@@ -764,7 +746,7 @@ void Spatial::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "transform", PROPERTY_HINT_NONE, ""), "set_transform", "get_transform");
ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_translation", "get_translation");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_deg", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_deg", "get_rotation_deg");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale");
ADD_GROUP("Visibility", "");
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index b912d1f906..8f53b4a066 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -106,10 +106,6 @@ class Spatial : public Node {
void _notify_dirty();
void _propagate_transform_changed(Spatial *p_origin);
- // Deprecated, should be removed in a future version.
- void _set_rotation_deg(const Vector3 &p_euler_deg);
- Vector3 _get_rotation_deg() const;
-
void _propagate_visibility_changed();
protected:
@@ -136,12 +132,12 @@ public:
void set_translation(const Vector3 &p_translation);
void set_rotation(const Vector3 &p_euler_rad);
- void set_rotation_in_degrees(const Vector3 &p_euler_deg);
+ void set_rotation_degrees(const Vector3 &p_euler_deg);
void set_scale(const Vector3 &p_scale);
Vector3 get_translation() const;
Vector3 get_rotation() const;
- Vector3 get_rotation_in_degrees() const;
+ Vector3 get_rotation_degrees() const;
Vector3 get_scale() const;
void set_transform(const Transform &p_transform);
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 49a3205f21..18ebc22c8b 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -188,7 +188,7 @@ void SpriteBase3D::_queue_update() {
call_deferred(SceneStringNames::get_singleton()->_im_update);
}
-Rect3 SpriteBase3D::get_aabb() const {
+AABB SpriteBase3D::get_aabb() const {
return aabb;
}
@@ -407,7 +407,7 @@ void Sprite3D::_draw() {
}
}
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < 4; i++) {
VS::get_singleton()->immediate_normal(immediate, normal);
@@ -698,7 +698,7 @@ void AnimatedSprite3D::_draw() {
}
}
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < 4; i++) {
VS::get_singleton()->immediate_normal(immediate, normal);
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index 1165392cb2..d18553a504 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -71,7 +71,7 @@ private:
Vector3::Axis axis;
float pixel_size;
- Rect3 aabb;
+ AABB aabb;
RID immediate;
@@ -87,7 +87,7 @@ protected:
void _notification(int p_what);
static void _bind_methods();
virtual void _draw() = 0;
- _FORCE_INLINE_ void set_aabb(const Rect3 &p_aabb) { aabb = p_aabb; }
+ _FORCE_INLINE_ void set_aabb(const AABB &p_aabb) { aabb = p_aabb; }
_FORCE_INLINE_ RID &get_immediate() { return immediate; }
void _queue_update();
@@ -130,7 +130,7 @@ public:
virtual Rect2 get_item_rect() const = 0;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
SpriteBase3D();
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index d3203bacec..47144c4b78 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -60,7 +60,7 @@ void VisibilityNotifier::_exit_camera(Camera *p_camera) {
}
}
-void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) {
+void VisibilityNotifier::set_aabb(const AABB &p_aabb) {
if (aabb == p_aabb)
return;
@@ -74,7 +74,7 @@ void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) {
update_gizmo();
}
-Rect3 VisibilityNotifier::get_aabb() const {
+AABB VisibilityNotifier::get_aabb() const {
return aabb;
}
@@ -108,7 +108,7 @@ void VisibilityNotifier::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier::get_aabb);
ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier::is_on_screen);
- ADD_PROPERTY(PropertyInfo(Variant::RECT3, "aabb"), "set_aabb", "get_aabb");
+ ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb");
ADD_SIGNAL(MethodInfo("camera_entered", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
ADD_SIGNAL(MethodInfo("camera_exited", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
@@ -118,7 +118,7 @@ void VisibilityNotifier::_bind_methods() {
VisibilityNotifier::VisibilityNotifier() {
- aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
+ aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
set_notify_transform(true);
}
@@ -252,8 +252,8 @@ void VisibilityEnabler::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "pause_animations"), "set_enabler", "is_enabler_enabled", ENABLER_PAUSE_ANIMATIONS);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "freeze_bodies"), "set_enabler", "is_enabler_enabled", ENABLER_FREEZE_BODIES);
- BIND_ENUM_CONSTANT(ENABLER_FREEZE_BODIES);
BIND_ENUM_CONSTANT(ENABLER_PAUSE_ANIMATIONS);
+ BIND_ENUM_CONSTANT(ENABLER_FREEZE_BODIES);
BIND_ENUM_CONSTANT(ENABLER_MAX);
}
diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h
index 0b83e0534e..fc06cf5aec 100644
--- a/scene/3d/visibility_notifier.h
+++ b/scene/3d/visibility_notifier.h
@@ -39,7 +39,7 @@ class VisibilityNotifier : public Spatial {
Set<Camera *> cameras;
- Rect3 aabb;
+ AABB aabb;
protected:
virtual void _screen_enter() {}
@@ -53,8 +53,8 @@ protected:
void _exit_camera(Camera *p_camera);
public:
- void set_aabb(const Rect3 &p_aabb);
- Rect3 get_aabb() const;
+ void set_aabb(const AABB &p_aabb);
+ AABB get_aabb() const;
bool is_on_screen() const;
VisibilityNotifier();
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index fa35d982eb..b92e7ead04 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -33,7 +33,7 @@
#include "servers/visual_server.h"
#include "skeleton.h"
-Rect3 VisualInstance::get_transformed_aabb() const {
+AABB VisualInstance::get_transformed_aabb() const {
return get_global_transform().xform(get_aabb());
}
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index c405236d2c..5827f1e1fb 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -62,10 +62,10 @@ public:
};
RID get_instance() const;
- virtual Rect3 get_aabb() const = 0;
+ virtual AABB get_aabb() const = 0;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const = 0;
- virtual Rect3 get_transformed_aabb() const; // helper
+ virtual AABB get_transformed_aabb() const; // helper
void set_base(const RID &p_base);