summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/audio/audio_filter_sw.cpp2
-rw-r--r--servers/audio/audio_stream.cpp5
-rw-r--r--servers/audio/audio_stream.h2
-rw-r--r--servers/audio/effects/audio_effect_record.cpp3
-rw-r--r--servers/audio/effects/audio_effect_spectrum_analyzer.cpp4
-rw-r--r--servers/audio_server.cpp17
-rw-r--r--servers/audio_server.h5
-rw-r--r--servers/physics/broad_phase_octree.cpp2
-rw-r--r--servers/physics/collision_object_sw.cpp7
-rw-r--r--servers/physics/collision_object_sw.h7
-rw-r--r--servers/physics/collision_solver_sat.cpp12
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.cpp1
-rw-r--r--servers/physics/space_sw.cpp4
-rw-r--r--servers/physics_2d/collision_object_2d_sw.cpp45
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h2
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp20
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h3
-rw-r--r--servers/physics_2d/space_2d_sw.cpp2
-rw-r--r--servers/server_wrap_mt_common.h2
-rw-r--r--servers/visual/visual_server_canvas.cpp2
-rw-r--r--servers/visual/visual_server_canvas.h4
-rw-r--r--servers/visual/visual_server_raster.cpp2
-rw-r--r--servers/visual/visual_server_scene.cpp6
-rw-r--r--servers/visual/visual_server_viewport.cpp2
-rw-r--r--servers/visual/visual_server_viewport.h3
-rw-r--r--servers/visual_server.cpp11
26 files changed, 118 insertions, 57 deletions
diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp
index 392938a2be..ca033f6079 100644
--- a/servers/audio/audio_filter_sw.cpp
+++ b/servers/audio/audio_filter_sw.cpp
@@ -154,7 +154,6 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
double tmpq = Math::sqrt(Q);
if (tmpq <= 0)
tmpq = 0.001;
- alpha = sin_v / (2 * tmpq);
double beta = Math::sqrt(tmpgain) / tmpq;
a0 = (tmpgain + 1.0) + (tmpgain - 1.0) * cos_v + beta * sin_v;
@@ -169,7 +168,6 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
double tmpq = Math::sqrt(Q);
if (tmpq <= 0)
tmpq = 0.001;
- alpha = sin_v / (2 * tmpq);
double beta = Math::sqrt(tmpgain) / tmpq;
a0 = (tmpgain + 1.0) - (tmpgain - 1.0) * cos_v + beta * sin_v;
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 1a6430c499..17f5e158a7 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -49,8 +49,9 @@ void AudioStreamPlaybackResampled::_begin_resample() {
void AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
float target_rate = AudioServer::get_singleton()->get_mix_rate();
+ float global_rate_scale = AudioServer::get_singleton()->get_global_rate_scale();
- uint64_t mix_increment = uint64_t(((get_stream_sampling_rate() * p_rate_scale) / double(target_rate)) * double(FP_LEN));
+ uint64_t mix_increment = uint64_t(((get_stream_sampling_rate() * p_rate_scale) / double(target_rate * global_rate_scale)) * double(FP_LEN));
for (int i = 0; i < p_frames; i++) {
@@ -223,7 +224,7 @@ float AudioStreamPlaybackMicrophone::get_playback_position() const {
}
void AudioStreamPlaybackMicrophone::seek(float p_time) {
- return; // Can't seek a microphone input
+ // Can't seek a microphone input
}
AudioStreamPlaybackMicrophone::~AudioStreamPlaybackMicrophone() {
diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h
index 8f023c0401..ef9f8ea92a 100644
--- a/servers/audio/audio_stream.h
+++ b/servers/audio/audio_stream.h
@@ -119,7 +119,7 @@ public:
class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled {
- GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback);
+ GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlaybackResampled);
friend class AudioStreamMicrophone;
bool active;
diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp
index abf9d5593c..acf27d2bbf 100644
--- a/servers/audio/effects/audio_effect_record.cpp
+++ b/servers/audio/effects/audio_effect_record.cpp
@@ -216,6 +216,9 @@ Ref<AudioStreamSample> AudioEffectRecord::get_recording() const {
PoolVector<uint8_t> dst_data;
+ ERR_FAIL_COND_V(current_instance.is_null(), NULL);
+ ERR_FAIL_COND_V(current_instance->recording_data.size(), NULL);
+
if (dst_format == AudioStreamSample::FORMAT_8_BITS) {
int data_size = current_instance->recording_data.size();
dst_data.resize(data_size);
diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
index 305f9046c3..bb1daf04a4 100644
--- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
+++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
@@ -231,8 +231,8 @@ Ref<AudioEffectInstance> AudioEffectSpectrumAnalyzer::instance() {
return ins;
}
-void AudioEffectSpectrumAnalyzer::set_buffer_length(float p_volume) {
- buffer_length = p_volume;
+void AudioEffectSpectrumAnalyzer::set_buffer_length(float p_seconds) {
+ buffer_length = p_seconds;
}
float AudioEffectSpectrumAnalyzer::get_buffer_length() const {
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index fc3ecedd03..a6473d69c0 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -944,6 +944,15 @@ bool AudioServer::is_bus_channel_active(int p_bus, int p_channel) const {
return buses[p_bus]->channels[p_channel].active;
}
+void AudioServer::set_global_rate_scale(float p_scale) {
+
+ global_rate_scale = p_scale;
+}
+float AudioServer::get_global_rate_scale() const {
+
+ return global_rate_scale;
+}
+
void AudioServer::init_channels_and_buffers() {
channel_count = get_channel_count();
temp_buffer.resize(channel_count);
@@ -1352,6 +1361,9 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_bus_peak_volume_left_db", "bus_idx", "channel"), &AudioServer::get_bus_peak_volume_left_db);
ClassDB::bind_method(D_METHOD("get_bus_peak_volume_right_db", "bus_idx", "channel"), &AudioServer::get_bus_peak_volume_right_db);
+ ClassDB::bind_method(D_METHOD("set_global_rate_scale", "scale"), &AudioServer::set_global_rate_scale);
+ ClassDB::bind_method(D_METHOD("get_global_rate_scale"), &AudioServer::get_global_rate_scale);
+
ClassDB::bind_method(D_METHOD("lock"), &AudioServer::lock);
ClassDB::bind_method(D_METHOD("unlock"), &AudioServer::unlock);
@@ -1372,6 +1384,10 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bus_layout", "bus_layout"), &AudioServer::set_bus_layout);
ClassDB::bind_method(D_METHOD("generate_bus_layout"), &AudioServer::generate_bus_layout);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "bus_count"), "set_bus_count", "get_bus_count");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "device"), "set_device", "get_device");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rate_scale"), "set_global_rate_scale", "get_global_rate_scale");
+
ADD_SIGNAL(MethodInfo("bus_layout_changed"));
BIND_ENUM_CONSTANT(SPEAKER_MODE_STEREO);
@@ -1396,6 +1412,7 @@ AudioServer::AudioServer() {
#endif
mix_time = 0;
mix_size = 0;
+ global_rate_scale = 1;
}
AudioServer::~AudioServer() {
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 942fe7bc87..b0fff9d4b7 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -181,6 +181,8 @@ private:
int channel_count;
int to_mix;
+ float global_rate_scale;
+
struct Bus {
StringName name;
@@ -339,6 +341,9 @@ public:
bool is_bus_channel_active(int p_bus, int p_channel) const;
+ void set_global_rate_scale(float p_scale);
+ float get_global_rate_scale() const;
+
virtual void init();
virtual void finish();
virtual void update();
diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp
index 94bf274f9c..1b59779bd6 100644
--- a/servers/physics/broad_phase_octree.cpp
+++ b/servers/physics/broad_phase_octree.cpp
@@ -45,7 +45,7 @@ void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) {
void BroadPhaseOctree::set_static(ID p_id, bool p_static) {
CollisionObjectSW *it = octree.get(p_id);
- octree.set_pairable(p_id, p_static ? false : true, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1?
+ octree.set_pairable(p_id, !p_static, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1?
}
void BroadPhaseOctree::remove(ID p_id) {
diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp
index b1c21290ab..39de440da2 100644
--- a/servers/physics/collision_object_sw.cpp
+++ b/servers/physics/collision_object_sw.cpp
@@ -76,6 +76,13 @@ void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_tran
//_shapes_changed();
}
+void CollisionObjectSW::set_shape_as_disabled(int p_idx, bool p_enable) {
+ shapes.write[p_idx].disabled = p_enable;
+ if (!pending_shape_update_list.in_list()) {
+ PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+}
+
void CollisionObjectSW::remove_shape(ShapeSW *p_shape) {
//remove a shape, all the times it appears
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index c2c3fe0e5a..895eda8528 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -139,8 +139,11 @@ public:
_FORCE_INLINE_ void set_ray_pickable(bool p_enable) { ray_pickable = p_enable; }
_FORCE_INLINE_ bool is_ray_pickable() const { return ray_pickable; }
- _FORCE_INLINE_ void set_shape_as_disabled(int p_idx, bool p_enable) { shapes.write[p_idx].disabled = p_enable; }
- _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const { return shapes[p_idx].disabled; }
+ void set_shape_as_disabled(int p_idx, bool p_enable);
+ _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const {
+ CRASH_BAD_INDEX(p_idx, shapes.size());
+ return shapes[p_idx].disabled;
+ }
_FORCE_INLINE_ void set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; }
_FORCE_INLINE_ uint32_t get_collision_layer() const { return collision_layer; }
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index 3073cc8b11..a13fa65009 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -538,8 +538,6 @@ static void _collision_sphere_capsule(const ShapeSW *p_a, const Transform &p_tra
template <bool withMargin>
static void _collision_sphere_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
@@ -835,8 +833,6 @@ static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transf
template <bool withMargin>
static void _collision_box_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
@@ -1117,8 +1113,6 @@ static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_tr
template <bool withMargin>
static void _collision_capsule_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
@@ -1243,20 +1237,14 @@ static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_trans
template <bool withMargin>
static void _collision_cylinder_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
static void _collision_cylinder_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
static void _collision_cylinder_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
- return;
}
template <bool withMargin>
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp
index 813d9b7704..a9fe045856 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics/joints/generic_6dof_joint_sw.cpp
@@ -421,7 +421,6 @@ void Generic6DOFJointSW::calcAnchorPos(void) {
const Vector3 &pA = m_calculatedTransformA.origin;
const Vector3 &pB = m_calculatedTransformB.origin;
m_AnchorPos = pA * weight + pB * (real_t(1.0) - weight);
- return;
} // Generic6DOFJointSW::calcAnchorPos()
void Generic6DOFJointSW::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) {
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 8b9f210850..f3a4cbed24 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -118,7 +118,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
continue;
- if (p_pick_ray && !(static_cast<CollisionObjectSW *>(space->intersection_query_results[i])->is_ray_pickable()))
+ if (p_pick_ray && !(space->intersection_query_results[i]->is_ray_pickable()))
continue;
if (p_exclude.has(space->intersection_query_results[i]->get_self()))
@@ -439,7 +439,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
continue;
}
- if (rcd.best_len == 0)
+ if (rcd.best_len == 0 || !rcd.best_object)
return false;
r_info->collider_id = rcd.best_object->get_instance_id();
diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp
index 445a2e0613..f556638db1 100644
--- a/servers/physics_2d/collision_object_2d_sw.cpp
+++ b/servers/physics_2d/collision_object_2d_sw.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "collision_object_2d_sw.h"
+#include "servers/physics_2d/physics_2d_server_sw.h"
#include "space_2d_sw.h"
void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_transform, bool p_disabled) {
@@ -43,8 +44,12 @@ void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_tra
s.one_way_collision_margin = 0;
shapes.push_back(s);
p_shape->add_owner(this);
- _update_shapes();
- _shapes_changed();
+
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
@@ -54,8 +59,12 @@ void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
shapes.write[p_index].shape = p_shape;
p_shape->add_owner(this);
- _update_shapes();
- _shapes_changed();
+
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::set_shape_metadata(int p_index, const Variant &p_metadata) {
@@ -70,8 +79,12 @@ void CollisionObject2DSW::set_shape_transform(int p_index, const Transform2D &p_
shapes.write[p_index].xform = p_transform;
shapes.write[p_index].xform_inv = p_transform.affine_inverse();
- _update_shapes();
- _shapes_changed();
+
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) {
@@ -89,9 +102,15 @@ void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) {
if (p_disabled && shape.bpid != 0) {
space->get_broadphase()->remove(shape.bpid);
shape.bpid = 0;
- _update_shapes();
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes();
} else if (!p_disabled && shape.bpid == 0) {
- _update_shapes(); // automatically adds shape with bpid == 0
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes(); // automatically adds shape with bpid == 0
}
}
@@ -122,8 +141,11 @@ void CollisionObject2DSW::remove_shape(int p_index) {
shapes[p_index].shape->remove_owner(this);
shapes.remove(p_index);
- _update_shapes();
- _shapes_changed();
+ if (!pending_shape_update_list.in_list()) {
+ Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ // _update_shapes();
+ // _shapes_changed();
}
void CollisionObject2DSW::_set_static(bool p_static) {
@@ -239,7 +261,8 @@ void CollisionObject2DSW::_shape_changed() {
_shapes_changed();
}
-CollisionObject2DSW::CollisionObject2DSW(Type p_type) {
+CollisionObject2DSW::CollisionObject2DSW(Type p_type) :
+ pending_shape_update_list(this) {
_static = true;
type = p_type;
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index fa18e61262..ed59469878 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -78,6 +78,8 @@ private:
uint32_t collision_layer;
bool _static;
+ SelfList<CollisionObject2DSW> pending_shape_update_list;
+
void _update_shapes();
protected:
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 0efa15d43e..cc656d3b73 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -902,6 +902,8 @@ void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
body->apply_torque_impulse(p_torque);
}
@@ -910,6 +912,8 @@ void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, con
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
body->apply_impulse(p_pos, p_impulse);
body->wakeup();
};
@@ -944,6 +948,8 @@ void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
Vector2 v = body->get_linear_velocity();
Vector2 axis = p_axis_velocity.normalized();
v -= axis * axis.dot(v);
@@ -1052,6 +1058,8 @@ bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from,
ERR_FAIL_COND_V(!body->get_space(), false);
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
+ _update_shapes();
+
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes);
}
@@ -1238,6 +1246,8 @@ Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const
void Physics2DServerSW::free(RID p_rid) {
+ _update_shapes(); // just in case
+
if (shape_owner.owns(p_rid)) {
Shape2DSW *shape = shape_owner.get(p_rid);
@@ -1335,6 +1345,8 @@ void Physics2DServerSW::step(real_t p_step) {
if (!active)
return;
+ _update_shapes();
+
doing_sync = false;
last_step = p_step;
@@ -1418,6 +1430,14 @@ void Physics2DServerSW::finish() {
memdelete(direct_state);
};
+void Physics2DServerSW::_update_shapes() {
+
+ while (pending_shape_update_list.first()) {
+ pending_shape_update_list.first()->self()->_shape_changed();
+ pending_shape_update_list.remove(pending_shape_update_list.first());
+ }
+}
+
int Physics2DServerSW::get_process_info(ProcessInfo p_info) {
switch (p_info) {
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index adc011af40..72625c397c 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -70,6 +70,9 @@ class Physics2DServerSW : public Physics2DServer {
static Physics2DServerSW *singletonsw;
//void _clear_query(Query2DSW *p_query);
+ friend class CollisionObject2DSW;
+ SelfList<CollisionObject2DSW>::List pending_shape_update_list;
+ void _update_shapes();
RID _shape_create(ShapeType p_shape);
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index e2b1bb9da4..7c89c43f36 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -442,7 +442,7 @@ bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_sh
continue;
}
- if (rcd.best_len == 0)
+ if (rcd.best_len == 0 || !rcd.best_object)
return false;
r_info->collider_id = rcd.best_object->get_instance_id();
diff --git a/servers/server_wrap_mt_common.h b/servers/server_wrap_mt_common.h
index f0ab256374..a6f595d776 100644
--- a/servers/server_wrap_mt_common.h
+++ b/servers/server_wrap_mt_common.h
@@ -50,7 +50,7 @@
} \
void m_type##_free_cached_ids() { \
while (m_type##_id_pool.size()) { \
- free(m_type##_id_pool.front()->get()); \
+ server_name->free(m_type##_id_pool.front()->get()); \
m_type##_id_pool.pop_front(); \
} \
} \
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index d5e154a7fc..66e2429bd0 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -783,7 +783,7 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector
ERR_FAIL_COND(!p_bones.empty() && p_bones.size() != vertex_count * 4);
ERR_FAIL_COND(!p_weights.empty() && p_weights.size() != vertex_count * 4);
- Vector<int> indices = p_indices;
+ const Vector<int> &indices = p_indices;
int count = p_count * 3;
diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h
index 26424f927e..28a8770c90 100644
--- a/servers/visual/visual_server_canvas.h
+++ b/servers/visual/visual_server_canvas.h
@@ -84,8 +84,8 @@ public:
if (Math::is_equal_approx(p_left->ysort_pos.y, p_right->ysort_pos.y))
return p_left->ysort_pos.x < p_right->ysort_pos.x;
- else
- return p_left->ysort_pos.y < p_right->ysort_pos.y;
+
+ return p_left->ysort_pos.y < p_right->ysort_pos.y;
}
};
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index d45bda72b7..7aded4e816 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -77,6 +77,8 @@ void VisualServerRaster::free(RID p_rid) {
return;
if (VSG::scene->free(p_rid))
return;
+ if (VSG::scene_render->free(p_rid))
+ return;
}
/* EVENT QUEUING */
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 3ee23e9290..faf5a1f8fa 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -3387,11 +3387,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
RID mat = VSG::storage->immediate_get_material(p_instance->base);
- if (!mat.is_valid() || VSG::storage->material_casts_shadows(mat)) {
- can_cast_shadows = true;
- } else {
- can_cast_shadows = false;
- }
+ can_cast_shadows = !mat.is_valid() || VSG::storage->material_casts_shadows(mat);
if (mat.is_valid() && VSG::storage->material_is_animated(mat)) {
is_animated = true;
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index b7c54caffd..f8ed035766 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -253,8 +253,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
} else {
_draw_3d(p_viewport, p_eye);
}
-
- scenario_draw_canvas_bg = false;
}
//VSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow);
diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h
index 43bbcb66c3..bdd4c1d4f2 100644
--- a/servers/visual/visual_server_viewport.h
+++ b/servers/visual/visual_server_viewport.h
@@ -138,9 +138,8 @@ public:
if (left_to_screen == right_to_screen) {
return p_left->parent == p_right->self;
- } else {
- return right_to_screen;
}
+ return right_to_screen;
}
};
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 60be63fd24..c6468694fd 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -917,7 +917,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
}
r_offsets[i] = elem_size;
continue;
- } break;
+ }
default: {
ERR_FAIL_V(0);
}
@@ -953,15 +953,12 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
switch (var.get_type()) {
case Variant::POOL_VECTOR2_ARRAY: {
PoolVector<Vector2> v2 = var;
- array_len = v2.size();
} break;
case Variant::POOL_VECTOR3_ARRAY: {
PoolVector<Vector3> v3 = var;
- array_len = v3.size();
} break;
default: {
Array v = var;
- array_len = v.size();
} break;
}
@@ -1151,7 +1148,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
if (err) {
ERR_EXPLAIN("Invalid array format for surface");
- ERR_FAIL_COND(err != OK);
+ ERR_FAIL();
}
Vector<PoolVector<uint8_t> > blend_shape_data;
@@ -1165,9 +1162,9 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
AABB laabb;
Error err2 = _surface_set_data(p_blend_shapes[i], format & ~ARRAY_FORMAT_INDEX, offsets, total_elem_size, vertex_array_shape, array_len, noindex, 0, laabb, bone_aabb);
aabb.merge_with(laabb);
- if (err2) {
+ if (err2 != OK) {
ERR_EXPLAIN("Invalid blend shape array format for surface");
- ERR_FAIL_COND(err2 != OK);
+ ERR_FAIL();
}
blend_shape_data.push_back(vertex_array_shape);