summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/audio/audio_rb_resampler.cpp2
-rw-r--r--servers/physics/body_pair_sw.cpp42
-rw-r--r--servers/physics/body_sw.cpp16
-rw-r--r--servers/physics/body_sw.h8
-rw-r--r--servers/physics/collision_solver_sat.cpp3
-rw-r--r--servers/physics/physics_server_sw.cpp20
-rw-r--r--servers/physics/physics_server_sw.h70
-rw-r--r--servers/physics_2d/body_2d_sw.cpp16
-rw-r--r--servers/physics_2d/body_2d_sw.h8
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp42
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp16
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h4
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h3
-rw-r--r--servers/physics_2d_server.h13
-rw-r--r--servers/physics_server.cpp4
-rw-r--r--servers/physics_server.h79
-rw-r--r--servers/visual/rasterizer.h6
-rw-r--r--servers/visual/visual_server_scene.cpp16
-rw-r--r--servers/visual_server.cpp175
-rw-r--r--servers/visual_server.h5
20 files changed, 522 insertions, 26 deletions
diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp
index 9faa4056c3..3414351681 100644
--- a/servers/audio/audio_rb_resampler.cpp
+++ b/servers/audio/audio_rb_resampler.cpp
@@ -100,6 +100,8 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
if (C == 6) {
+ // FIXME: Lot of unused assignments here, but it seems like intermediate calculations
+ // should be done as for C == 2 (C == 4 also has some unused assignments).
float v0 = rb[(pos * 6) + 0];
float v1 = rb[(pos * 6) + 1];
float v2 = rb[(pos * 6) + 2];
diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp
index 2a6a9e08ae..5a41b621eb 100644
--- a/servers/physics/body_pair_sw.cpp
+++ b/servers/physics/body_pair_sw.cpp
@@ -211,6 +211,44 @@ bool BodyPairSW::_test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Tran
return true;
}
+real_t combine_bounce(BodySW *A, BodySW *B) {
+ const PhysicsServer::CombineMode cm = A->get_bounce_combine_mode();
+
+ switch (cm) {
+ case PhysicsServer::COMBINE_MODE_INHERIT:
+ if (B->get_bounce_combine_mode() != PhysicsServer::COMBINE_MODE_INHERIT)
+ return combine_bounce(B, A);
+ // else use MAX [This is used when the two bodies doesn't use physical material]
+ case PhysicsServer::COMBINE_MODE_MAX:
+ return MAX(A->get_bounce(), B->get_bounce());
+ case PhysicsServer::COMBINE_MODE_MIN:
+ return MIN(A->get_bounce(), B->get_bounce());
+ case PhysicsServer::COMBINE_MODE_MULTIPLY:
+ return A->get_bounce() * B->get_bounce();
+ default: // Is always PhysicsServer::COMBINE_MODE_AVERAGE:
+ return (A->get_bounce() + B->get_bounce()) / 2;
+ }
+}
+
+real_t combine_friction(BodySW *A, BodySW *B) {
+ const PhysicsServer::CombineMode cm = A->get_friction_combine_mode();
+
+ switch (cm) {
+ case PhysicsServer::COMBINE_MODE_INHERIT:
+ if (B->get_friction_combine_mode() != PhysicsServer::COMBINE_MODE_INHERIT)
+ return combine_friction(B, A);
+ // else use Multiply [This is used when the two bodies doesn't use physical material]
+ case PhysicsServer::COMBINE_MODE_MULTIPLY:
+ return A->get_friction() * B->get_friction();
+ case PhysicsServer::COMBINE_MODE_MAX:
+ return MAX(A->get_friction(), B->get_friction());
+ case PhysicsServer::COMBINE_MODE_MIN:
+ return MIN(A->get_friction(), B->get_friction());
+ default: // Is always PhysicsServer::COMBINE_MODE_AVERAGE:
+ return (A->get_friction() + B->get_friction()) / 2;
+ }
+}
+
bool BodyPairSW::setup(real_t p_step) {
//cannot collide
@@ -331,7 +369,7 @@ bool BodyPairSW::setup(real_t p_step) {
c.acc_bias_impulse = 0;
c.acc_bias_impulse_center_of_mass = 0;
- c.bounce = MAX(A->get_bounce(), B->get_bounce());
+ c.bounce = combine_bounce(A, B);
if (c.bounce) {
Vector3 crA = A->get_angular_velocity().cross(c.rA);
@@ -421,7 +459,7 @@ void BodyPairSW::solve(real_t p_step) {
//friction impulse
- real_t friction = A->get_friction() * B->get_friction();
+ real_t friction = combine_friction(A, B);
Vector3 lvA = A->get_linear_velocity() + A->get_angular_velocity().cross(c.rA);
Vector3 lvB = B->get_linear_velocity() + B->get_angular_velocity().cross(c.rB);
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index cc9681193c..59f987fc17 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -423,6 +423,22 @@ void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) {
area_angular_damp += p_area->get_angular_damp();
}
+void BodySW::set_combine_mode(PhysicsServer::BodyParameter p_param, PhysicsServer::CombineMode p_mode) {
+ if (p_param == PhysicsServer::BODY_PARAM_BOUNCE) {
+ bounce_combine_mode = p_mode;
+ } else {
+ friction_combine_mode = p_mode;
+ }
+}
+
+PhysicsServer::CombineMode BodySW::get_combine_mode(PhysicsServer::BodyParameter p_param) const {
+ if (p_param == PhysicsServer::BODY_PARAM_BOUNCE) {
+ return bounce_combine_mode;
+ } else {
+ return friction_combine_mode;
+ }
+}
+
void BodySW::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
if (lock) {
locked_axis |= p_axis;
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index fd2ab16b84..25eb20f5d8 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -49,6 +49,8 @@ class BodySW : public CollisionObjectSW {
real_t mass;
real_t bounce;
real_t friction;
+ PhysicsServer::CombineMode bounce_combine_mode;
+ PhysicsServer::CombineMode friction_combine_mode;
real_t linear_damp;
real_t angular_damp;
@@ -298,6 +300,12 @@ public:
_FORCE_INLINE_ Vector3 get_gravity() const { return gravity; }
_FORCE_INLINE_ real_t get_bounce() const { return bounce; }
+ void set_combine_mode(PhysicsServer::BodyParameter p_param, PhysicsServer::CombineMode p_mode);
+ PhysicsServer::CombineMode get_combine_mode(PhysicsServer::BodyParameter p_param) const;
+
+ _FORCE_INLINE_ PhysicsServer::CombineMode get_bounce_combine_mode() const { return bounce_combine_mode; }
+ _FORCE_INLINE_ PhysicsServer::CombineMode get_friction_combine_mode() const { return friction_combine_mode; }
+
void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock);
bool is_axis_locked(PhysicsServer::BodyAxis p_axis) const;
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index e587485fcb..44b7c9ac34 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -217,8 +217,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
// generate contacts
//Plane plane_A(p_points_A[0],p_points_A[1],p_points_A[2]);
- int added = 0;
-
for (int i = 0; i < clipbuf_len; i++) {
real_t d = plane_B.distance_to(clipbuf_src[i]);
@@ -233,7 +231,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
continue;
p_callback->call(clipbuf_src[i], closest_B);
- added++;
}
}
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index 6c25ad43f9..f1e0cbef29 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -701,6 +701,20 @@ real_t PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const
return body->get_param(p_param);
};
+void PhysicsServerSW::body_set_combine_mode(RID p_body, BodyParameter p_param, CombineMode p_mode) {
+ BodySW *body = body_owner.get(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_combine_mode(p_param, p_mode);
+}
+
+PhysicsServer::CombineMode PhysicsServerSW::body_get_combine_mode(RID p_body, BodyParameter p_param) const {
+ BodySW *body = body_owner.get(p_body);
+ ERR_FAIL_COND_V(!body, COMBINE_MODE_INHERIT);
+
+ return body->get_combine_mode(p_param);
+}
+
void PhysicsServerSW::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -1367,6 +1381,8 @@ void PhysicsServerSW::init() {
void PhysicsServerSW::step(real_t p_step) {
+#ifndef _3D_DISABLED
+
if (!active)
return;
@@ -1387,6 +1403,7 @@ void PhysicsServerSW::step(real_t p_step) {
active_objects += E->get()->get_active_objects();
collision_pairs += E->get()->get_collision_pairs();
}
+#endif
}
void PhysicsServerSW::sync(){
@@ -1395,6 +1412,8 @@ void PhysicsServerSW::sync(){
void PhysicsServerSW::flush_queries() {
+#ifndef _3D_DISABLED
+
if (!active)
return;
@@ -1441,6 +1460,7 @@ void PhysicsServerSW::flush_queries() {
ScriptDebugger::get_singleton()->add_profiling_frame_data("physics", values);
}
+#endif
};
void PhysicsServerSW::finish() {
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index 3f56ba26d0..7e9700d026 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -188,6 +188,10 @@ public:
virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value);
virtual real_t body_get_param(RID p_body, BodyParameter p_param) const;
+ /// p_param accept only Bounce and Friction
+ virtual void body_set_combine_mode(RID p_body, BodyParameter p_param, CombineMode p_mode);
+ virtual CombineMode body_get_combine_mode(RID p_body, BodyParameter p_param) const;
+
virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin);
virtual real_t body_get_kinematic_safe_margin(RID p_body) const;
@@ -230,6 +234,72 @@ public:
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body);
+ /* SOFT BODY */
+
+ virtual RID soft_body_create(bool p_init_sleeping = false) { return RID(); }
+
+ virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) {}
+
+ virtual void soft_body_set_space(RID p_body, RID p_space) {}
+ virtual RID soft_body_get_space(RID p_body) const { return RID(); }
+
+ virtual void soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {}
+ virtual uint32_t soft_body_get_collision_layer(RID p_body) const { return 0; }
+
+ virtual void soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {}
+ virtual uint32_t soft_body_get_collision_mask(RID p_body) const { return 0; }
+
+ virtual void soft_body_add_collision_exception(RID p_body, RID p_body_b) {}
+ virtual void soft_body_remove_collision_exception(RID p_body, RID p_body_b) {}
+ virtual void soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {}
+
+ virtual void soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {}
+ virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const { return Variant(); }
+
+ virtual void soft_body_set_transform(RID p_body, const Transform &p_transform) {}
+ virtual Vector3 soft_body_get_vertex_position(RID p_body, int vertex_index) const { return Vector3(); }
+
+ virtual void soft_body_set_ray_pickable(RID p_body, bool p_enable) {}
+ virtual bool soft_body_is_ray_pickable(RID p_body) const { return false; }
+
+ virtual void soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {}
+ virtual int soft_body_get_simulation_precision(RID p_body) { return 0; }
+
+ virtual void soft_body_set_total_mass(RID p_body, real_t p_total_mass) {}
+ virtual real_t soft_body_get_total_mass(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {}
+ virtual real_t soft_body_get_linear_stiffness(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) {}
+ virtual real_t soft_body_get_areaAngular_stiffness(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) {}
+ virtual real_t soft_body_get_volume_stiffness(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {}
+ virtual real_t soft_body_get_pressure_coefficient(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) {}
+ virtual real_t soft_body_get_pose_matching_coefficient(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {}
+ virtual real_t soft_body_get_damping_coefficient(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {}
+ virtual real_t soft_body_get_drag_coefficient(RID p_body) { return 0.; }
+
+ virtual void soft_body_set_mesh(RID p_body, const REF &p_mesh) {}
+
+ virtual void soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {}
+ virtual Vector3 soft_body_get_point_global_position(RID p_body, int p_point_index) { return Vector3(); }
+
+ virtual Vector3 soft_body_get_point_offset(RID p_body, int p_point_index) const { return Vector3(); }
+
+ virtual void soft_body_remove_all_pinned_points(RID p_body) {}
+ virtual void soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {}
+ virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) { return 0; }
+
/* JOINT API */
virtual RID joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B);
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index aa063d6c1e..fcd2a65ee7 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -405,6 +405,22 @@ void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) {
area_angular_damp += p_area->get_angular_damp();
}
+void Body2DSW::set_combine_mode(Physics2DServer::BodyParameter p_param, Physics2DServer::CombineMode p_mode) {
+ if (p_param == Physics2DServer::BODY_PARAM_BOUNCE) {
+ bounce_combine_mode = p_mode;
+ } else {
+ friction_combine_mode = p_mode;
+ }
+}
+
+Physics2DServer::CombineMode Body2DSW::get_combine_mode(Physics2DServer::BodyParameter p_param) const {
+ if (p_param == Physics2DServer::BODY_PARAM_BOUNCE) {
+ return bounce_combine_mode;
+ } else {
+ return friction_combine_mode;
+ }
+}
+
void Body2DSW::integrate_forces(real_t p_step) {
if (mode == Physics2DServer::BODY_MODE_STATIC)
diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h
index 782adf3416..301bd6b299 100644
--- a/servers/physics_2d/body_2d_sw.h
+++ b/servers/physics_2d/body_2d_sw.h
@@ -54,6 +54,8 @@ class Body2DSW : public CollisionObject2DSW {
real_t mass;
real_t bounce;
real_t friction;
+ Physics2DServer::CombineMode bounce_combine_mode;
+ Physics2DServer::CombineMode friction_combine_mode;
real_t _inv_mass;
real_t _inv_inertia;
@@ -256,6 +258,12 @@ public:
_FORCE_INLINE_ real_t get_linear_damp() const { return linear_damp; }
_FORCE_INLINE_ real_t get_angular_damp() const { return angular_damp; }
+ void set_combine_mode(Physics2DServer::BodyParameter p_param, Physics2DServer::CombineMode p_mode);
+ Physics2DServer::CombineMode get_combine_mode(Physics2DServer::BodyParameter p_param) const;
+
+ _FORCE_INLINE_ Physics2DServer::CombineMode get_bounce_combine_mode() const { return bounce_combine_mode; }
+ _FORCE_INLINE_ Physics2DServer::CombineMode get_friction_combine_mode() const { return friction_combine_mode; }
+
void integrate_forces(real_t p_step);
void integrate_velocities(real_t p_step);
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index 61c0e0063f..be8dcf6fa8 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -219,6 +219,44 @@ bool BodyPair2DSW::_test_ccd(real_t p_step, Body2DSW *p_A, int p_shape_A, const
return true;
}
+real_t combine_bounce(Body2DSW *A, Body2DSW *B) {
+ const Physics2DServer::CombineMode cm = A->get_bounce_combine_mode();
+
+ switch (cm) {
+ case Physics2DServer::COMBINE_MODE_INHERIT:
+ if (B->get_bounce_combine_mode() != Physics2DServer::COMBINE_MODE_INHERIT)
+ return combine_bounce(B, A);
+ // else use MAX [This is used when the two bodies doesn't use physical material]
+ case Physics2DServer::COMBINE_MODE_MAX:
+ return MAX(A->get_bounce(), B->get_bounce());
+ case Physics2DServer::COMBINE_MODE_MIN:
+ return MIN(A->get_bounce(), B->get_bounce());
+ case Physics2DServer::COMBINE_MODE_MULTIPLY:
+ return A->get_bounce() * B->get_bounce();
+ default: // Is always Physics2DServer::COMBINE_MODE_AVERAGE:
+ return (A->get_bounce() + B->get_bounce()) / 2;
+ }
+}
+
+real_t combine_friction(Body2DSW *A, Body2DSW *B) {
+ const Physics2DServer::CombineMode cm = A->get_friction_combine_mode();
+
+ switch (cm) {
+ case Physics2DServer::COMBINE_MODE_INHERIT:
+ if (B->get_friction_combine_mode() != Physics2DServer::COMBINE_MODE_INHERIT)
+ return combine_friction(B, A);
+ // else use Multiply [This is used when the two bodies doesn't use physical material]
+ case Physics2DServer::COMBINE_MODE_MULTIPLY:
+ return A->get_friction() * B->get_friction();
+ case Physics2DServer::COMBINE_MODE_MAX:
+ return MAX(A->get_friction(), B->get_friction());
+ case Physics2DServer::COMBINE_MODE_MIN:
+ return MIN(A->get_friction(), B->get_friction());
+ default: // Is always Physics2DServer::COMBINE_MODE_AVERAGE:
+ return (A->get_friction() + B->get_friction()) / 2;
+ }
+}
+
bool BodyPair2DSW::setup(real_t p_step) {
//cannot collide
@@ -432,7 +470,7 @@ bool BodyPair2DSW::setup(real_t p_step) {
#endif
- c.bounce = MAX(A->get_bounce(), B->get_bounce());
+ c.bounce = combine_bounce(A, B);
if (c.bounce) {
Vector2 crA(-A->get_angular_velocity() * c.rA.y, A->get_angular_velocity() * c.rA.x);
@@ -488,7 +526,7 @@ void BodyPair2DSW::solve(real_t p_step) {
real_t jnOld = c.acc_normal_impulse;
c.acc_normal_impulse = MAX(jnOld + jn, 0.0f);
- real_t friction = A->get_friction() * B->get_friction();
+ real_t friction = combine_friction(A, B);
real_t jtMax = friction * c.acc_normal_impulse;
real_t jt = -vt * c.mass_tangent;
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index a473e0beb2..cfcef8cb04 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -789,6 +789,22 @@ real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) cons
return body->get_param(p_param);
};
+void Physics2DServerSW::body_set_combine_mode(RID p_body, BodyParameter p_param, CombineMode p_mode) {
+
+ Body2DSW *body = body_owner.get(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_combine_mode(p_param, p_mode);
+}
+
+Physics2DServer::CombineMode Physics2DServerSW::body_get_combine_mode(RID p_body, BodyParameter p_param) const {
+
+ Body2DSW *body = body_owner.get(p_body);
+ ERR_FAIL_COND_V(!body, COMBINE_MODE_INHERIT);
+
+ return body->get_combine_mode(p_param);
+}
+
void Physics2DServerSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
Body2DSW *body = body_owner.get(p_body);
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index e5961b9011..bf00746063 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -200,6 +200,10 @@ public:
virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value);
virtual real_t body_get_param(RID p_body, BodyParameter p_param) const;
+ /// p_param accept only Bounce and Friction
+ virtual void body_set_combine_mode(RID p_body, BodyParameter p_param, CombineMode p_mode);
+ virtual CombineMode body_get_combine_mode(RID p_body, BodyParameter p_param) const;
+
virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant);
virtual Variant body_get_state(RID p_body, BodyState p_state) const;
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
index 3119b930d7..a85cd5ef8d 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -211,6 +211,9 @@ public:
FUNC3(body_set_param, RID, BodyParameter, real_t);
FUNC2RC(real_t, body_get_param, RID, BodyParameter);
+ FUNC3(body_set_combine_mode, RID, BodyParameter, CombineMode);
+ FUNC2RC(CombineMode, body_get_combine_mode, RID, BodyParameter);
+
FUNC3(body_set_state, RID, BodyState, const Variant &);
FUNC2RC(Variant, body_get_state, RID, BodyState);
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index 1d04fbc5c6..89c649af49 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -416,6 +416,19 @@ public:
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value) = 0;
virtual float body_get_param(RID p_body, BodyParameter p_param) const = 0;
+ enum CombineMode {
+ COMBINE_MODE_MAX,
+ COMBINE_MODE_MIN,
+ COMBINE_MODE_MULTIPLY,
+ COMBINE_MODE_AVERAGE,
+
+ COMBINE_MODE_INHERIT /// Inherit from other body or use COMBINE_MODE_MAX (Restitution) COMBINE_MODE_MULTIPLY (Friction)
+ };
+
+ /// p_param accept only Bounce and Friction
+ virtual void body_set_combine_mode(RID p_body, BodyParameter p_param, CombineMode p_mode) = 0;
+ virtual CombineMode body_get_combine_mode(RID p_body, BodyParameter p_param) const = 0;
+
//state
enum BodyState {
BODY_STATE_TRANSFORM,
diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp
index de173491b2..b4bd4cb35f 100644
--- a/servers/physics_server.cpp
+++ b/servers/physics_server.cpp
@@ -400,6 +400,8 @@ void PhysicsShapeQueryResult::_bind_methods() {
void PhysicsServer::_bind_methods() {
+#ifndef _3D_DISABLED
+
ClassDB::bind_method(D_METHOD("shape_create", "type"), &PhysicsServer::shape_create);
ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer::shape_set_data);
@@ -737,6 +739,8 @@ void PhysicsServer::_bind_methods() {
BIND_ENUM_CONSTANT(BODY_AXIS_ANGULAR_X);
BIND_ENUM_CONSTANT(BODY_AXIS_ANGULAR_Y);
BIND_ENUM_CONSTANT(BODY_AXIS_ANGULAR_Z);
+
+#endif
}
PhysicsServer::PhysicsServer() {
diff --git a/servers/physics_server.h b/servers/physics_server.h
index 8ecf17c0e6..497d23c555 100644
--- a/servers/physics_server.h
+++ b/servers/physics_server.h
@@ -399,6 +399,19 @@ public:
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value) = 0;
virtual float body_get_param(RID p_body, BodyParameter p_param) const = 0;
+ enum CombineMode {
+ COMBINE_MODE_MAX,
+ COMBINE_MODE_MIN,
+ COMBINE_MODE_MULTIPLY,
+ COMBINE_MODE_AVERAGE,
+
+ COMBINE_MODE_INHERIT /// Inherit from other body or use COMBINE_MODE_MAX (Restitution) COMBINE_MODE_MULTIPLY (Friction)
+ };
+
+ /// p_param accept only Bounce and Friction
+ virtual void body_set_combine_mode(RID p_body, BodyParameter p_param, CombineMode p_mode) = 0;
+ virtual CombineMode body_get_combine_mode(RID p_body, BodyParameter p_param) const = 0;
+
virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin) = 0;
virtual real_t body_get_kinematic_safe_margin(RID p_body) const = 0;
@@ -477,6 +490,72 @@ public:
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL) = 0;
+ /* SOFT BODY */
+
+ virtual RID soft_body_create(bool p_init_sleeping = false) = 0;
+
+ virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) = 0;
+
+ virtual void soft_body_set_space(RID p_body, RID p_space) = 0;
+ virtual RID soft_body_get_space(RID p_body) const = 0;
+
+ virtual void soft_body_set_mesh(RID p_body, const REF &p_mesh) = 0;
+
+ virtual void soft_body_set_collision_layer(RID p_body, uint32_t p_layer) = 0;
+ virtual uint32_t soft_body_get_collision_layer(RID p_body) const = 0;
+
+ virtual void soft_body_set_collision_mask(RID p_body, uint32_t p_mask) = 0;
+ virtual uint32_t soft_body_get_collision_mask(RID p_body) const = 0;
+
+ virtual void soft_body_add_collision_exception(RID p_body, RID p_body_b) = 0;
+ virtual void soft_body_remove_collision_exception(RID p_body, RID p_body_b) = 0;
+ virtual void soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) = 0;
+
+ virtual void soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) = 0;
+ virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const = 0;
+
+ virtual void soft_body_set_transform(RID p_body, const Transform &p_transform) = 0;
+ virtual Vector3 soft_body_get_vertex_position(RID p_body, int vertex_index) const = 0;
+
+ virtual void soft_body_set_ray_pickable(RID p_body, bool p_enable) = 0;
+ virtual bool soft_body_is_ray_pickable(RID p_body) const = 0;
+
+ virtual void soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) = 0;
+ virtual int soft_body_get_simulation_precision(RID p_body) = 0;
+
+ virtual void soft_body_set_total_mass(RID p_body, real_t p_total_mass) = 0;
+ virtual real_t soft_body_get_total_mass(RID p_body) = 0;
+
+ virtual void soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) = 0;
+ virtual real_t soft_body_get_linear_stiffness(RID p_body) = 0;
+
+ virtual void soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) = 0;
+ virtual real_t soft_body_get_areaAngular_stiffness(RID p_body) = 0;
+
+ virtual void soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) = 0;
+ virtual real_t soft_body_get_volume_stiffness(RID p_body) = 0;
+
+ virtual void soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) = 0;
+ virtual real_t soft_body_get_pressure_coefficient(RID p_body) = 0;
+
+ virtual void soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) = 0;
+ virtual real_t soft_body_get_pose_matching_coefficient(RID p_body) = 0;
+
+ virtual void soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) = 0;
+ virtual real_t soft_body_get_damping_coefficient(RID p_body) = 0;
+
+ virtual void soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) = 0;
+ virtual real_t soft_body_get_drag_coefficient(RID p_body) = 0;
+
+ virtual void soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) = 0;
+ virtual Vector3 soft_body_get_point_global_position(RID p_body, int p_point_index) = 0;
+
+ virtual Vector3 soft_body_get_point_offset(RID p_body, int p_point_index) const = 0;
+
+ virtual void soft_body_remove_all_pinned_points(RID p_body) = 0;
+ virtual void soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) = 0;
+ virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) = 0;
+
/* JOINT API */
enum JointType {
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 0b37d266e7..a8f4377ce7 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -104,10 +104,12 @@ public:
VS::ShadowCastingSetting cast_shadows;
+ //fit in 32 bits
bool mirror : 8;
bool receive_shadows : 8;
bool visible : 8;
- bool baked_light : 8; //this flag is only to know if it actually did use baked light
+ bool baked_light : 4; //this flag is only to know if it actually did use baked light
+ bool redraw_if_visible : 4;
float depth; //used for sorting
@@ -131,6 +133,7 @@ public:
depth_layer = 0;
layer_mask = 1;
baked_light = false;
+ redraw_if_visible = false;
lightmap_capture = NULL;
}
};
@@ -277,6 +280,7 @@ public:
virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0;
+
virtual void mesh_clear(RID p_mesh) = 0;
/* MULTIMESH API */
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 697c890c9a..887cd7429a 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -820,6 +820,11 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
instance->baked_light = p_enabled;
} break;
+ case VS::INSTANCE_FLAG_REDRAW_FRAME_IF_VISIBLE: {
+
+ instance->redraw_if_visible = p_enabled;
+
+ } break;
}
}
void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
@@ -1644,7 +1649,8 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
}
void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
- // render to mono camera
+// render to mono camera
+#ifndef _3D_DISABLED
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -1679,6 +1685,7 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view
_prepare_scene(camera->transform, camera_matrix, ortho, camera->env, camera->visible_layers, p_scenario, p_shadow_atlas, RID());
_render_scene(camera->transform, camera_matrix, ortho, camera->env, p_scenario, p_shadow_atlas, RID(), -1);
+#endif
}
void VisualServerScene::render_camera(Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
@@ -1871,6 +1878,10 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
+ if (ins->redraw_if_visible) {
+ VisualServerRaster::redraw_request();
+ }
+
if (ins->base_type == VS::INSTANCE_PARTICLES) {
//particles visible? process them
VSG::storage->particles_request_process(ins->base);
@@ -2102,6 +2113,8 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
void VisualServerScene::render_empty_scene(RID p_scenario, RID p_shadow_atlas) {
+#ifndef _3D_DISABLED
+
Scenario *scenario = scenario_owner.getornull(p_scenario);
RID environment;
@@ -2110,6 +2123,7 @@ void VisualServerScene::render_empty_scene(RID p_scenario, RID p_shadow_atlas) {
else
environment = scenario->fallback_environment;
VSG::scene_render->render_scene(Transform(), CameraMatrix(), true, NULL, 0, NULL, 0, NULL, 0, environment, p_shadow_atlas, scenario->reflection_atlas, RID(), 0);
+#endif
}
bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) {
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index dffaccc0d4..1f3319dc04 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -187,16 +187,14 @@ RID VisualServer::_make_test_cube() {
PoolVector<float> tangents;
PoolVector<Vector3> uvs;
- int vtx_idx = 0;
-#define ADD_VTX(m_idx) \
- vertices.push_back(face_points[m_idx]); \
- normals.push_back(normal_points[m_idx]); \
- tangents.push_back(normal_points[m_idx][1]); \
- tangents.push_back(normal_points[m_idx][2]); \
- tangents.push_back(normal_points[m_idx][0]); \
- tangents.push_back(1.0); \
- uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0)); \
- vtx_idx++;
+#define ADD_VTX(m_idx) \
+ vertices.push_back(face_points[m_idx]); \
+ normals.push_back(normal_points[m_idx]); \
+ tangents.push_back(normal_points[m_idx][1]); \
+ tangents.push_back(normal_points[m_idx][2]); \
+ tangents.push_back(normal_points[m_idx][0]); \
+ tangents.push_back(1.0); \
+ uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));
for (int i = 0; i < 6; i++) {
@@ -795,6 +793,140 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
return OK;
}
+uint32_t VisualServer::mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const {
+ uint32_t offsets[ARRAY_MAX];
+ mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
+ return offsets[p_array_index];
+}
+
+uint32_t VisualServer::mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const {
+ uint32_t offsets[ARRAY_MAX];
+ return mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
+}
+
+uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const {
+
+ int total_elem_size = 0;
+
+ for (int i = 0; i < VS::ARRAY_MAX; i++) {
+
+ r_offsets[i] = 0; //reset
+
+ if (!(p_format & (1 << i))) // no array
+ continue;
+
+ int elem_size = 0;
+
+ switch (i) {
+
+ case VS::ARRAY_VERTEX: {
+
+ if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
+ elem_size = 2;
+ } else {
+ elem_size = 3;
+ }
+
+ if (p_format & ARRAY_COMPRESS_VERTEX) {
+ elem_size *= sizeof(int16_t);
+ } else {
+ elem_size *= sizeof(float);
+ }
+
+ if (elem_size == 6) {
+ elem_size = 8;
+ }
+
+ } break;
+ case VS::ARRAY_NORMAL: {
+
+ if (p_format & ARRAY_COMPRESS_NORMAL) {
+ elem_size = sizeof(uint32_t);
+ } else {
+ elem_size = sizeof(float) * 3;
+ }
+
+ } break;
+
+ case VS::ARRAY_TANGENT: {
+ if (p_format & ARRAY_COMPRESS_TANGENT) {
+ elem_size = sizeof(uint32_t);
+ } else {
+ elem_size = sizeof(float) * 4;
+ }
+
+ } break;
+ case VS::ARRAY_COLOR: {
+
+ if (p_format & ARRAY_COMPRESS_COLOR) {
+ elem_size = sizeof(uint32_t);
+ } else {
+ elem_size = sizeof(float) * 4;
+ }
+ } break;
+ case VS::ARRAY_TEX_UV: {
+ if (p_format & ARRAY_COMPRESS_TEX_UV) {
+ elem_size = sizeof(uint32_t);
+ } else {
+ elem_size = sizeof(float) * 2;
+ }
+
+ } break;
+
+ case VS::ARRAY_TEX_UV2: {
+ if (p_format & ARRAY_COMPRESS_TEX_UV2) {
+ elem_size = sizeof(uint32_t);
+ } else {
+ elem_size = sizeof(float) * 2;
+ }
+
+ } break;
+ case VS::ARRAY_WEIGHTS: {
+
+ if (p_format & ARRAY_COMPRESS_WEIGHTS) {
+ elem_size = sizeof(uint16_t) * 4;
+ } else {
+ elem_size = sizeof(float) * 4;
+ }
+
+ } break;
+ case VS::ARRAY_BONES: {
+
+ if (p_format & ARRAY_FLAG_USE_16_BIT_BONES) {
+ elem_size = sizeof(uint16_t) * 4;
+ } else {
+ elem_size = sizeof(uint32_t);
+ }
+
+ } break;
+ case VS::ARRAY_INDEX: {
+
+ if (p_index_len <= 0) {
+ ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
+ break;
+ }
+ /* determine whether using 16 or 32 bits indices */
+ if (p_vertex_len >= (1 << 16)) {
+
+ elem_size = 4;
+
+ } else {
+ elem_size = 2;
+ }
+ r_offsets[i] = elem_size;
+ continue;
+ } break;
+ default: {
+ ERR_FAIL_V(0);
+ }
+ }
+
+ r_offsets[i] = total_elem_size;
+ total_elem_size += elem_size;
+ }
+ return total_elem_size;
+}
+
void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, uint32_t p_compress_format) {
ERR_FAIL_INDEX(p_primitive, VS::PRIMITIVE_MAX);
@@ -1543,10 +1675,10 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("texture_debug_usage"), &VisualServer::_texture_debug_usage_bind);
ClassDB::bind_method(D_METHOD("textures_keep_original", "enable"), &VisualServer::textures_keep_original);
-
+#ifndef _3D_DISABLED
ClassDB::bind_method(D_METHOD("sky_create"), &VisualServer::sky_create);
ClassDB::bind_method(D_METHOD("sky_set_texture", "sky", "cube_map", "radiance_size"), &VisualServer::sky_set_texture);
-
+#endif
ClassDB::bind_method(D_METHOD("shader_create"), &VisualServer::shader_create);
ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &VisualServer::shader_set_code);
ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &VisualServer::shader_get_code);
@@ -1564,11 +1696,14 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass);
ClassDB::bind_method(D_METHOD("mesh_create"), &VisualServer::mesh_create);
+ ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_len", "index_len", "array_index"), &VisualServer::mesh_surface_get_format_offset);
+ ClassDB::bind_method(D_METHOD("mesh_surface_get_format_stride", "format", "vertex_len", "index_len"), &VisualServer::mesh_surface_get_format_stride);
ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primtive", "arrays", "blend_shapes", "compress_format"), &VisualServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(ARRAY_COMPRESS_DEFAULT));
ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_count", "mesh", "amount"), &VisualServer::mesh_set_blend_shape_count);
ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count);
ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode);
ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode);
+ ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &VisualServer::mesh_surface_update_region);
ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material);
ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material);
ClassDB::bind_method(D_METHOD("mesh_surface_get_array_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_len);
@@ -1603,7 +1738,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &VisualServer::multimesh_set_visible_instances);
ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &VisualServer::multimesh_get_visible_instances);
ClassDB::bind_method(D_METHOD("multimesh_set_as_bulk_array", "multimesh", "array"), &VisualServer::multimesh_set_as_bulk_array);
-
+#ifndef _3D_DISABLED
ClassDB::bind_method(D_METHOD("immediate_create"), &VisualServer::immediate_create);
ClassDB::bind_method(D_METHOD("immediate_begin", "immediate", "primitive", "texture"), &VisualServer::immediate_begin, DEFVAL(RID()));
ClassDB::bind_method(D_METHOD("immediate_vertex", "immediate", "vertex"), &VisualServer::immediate_vertex);
@@ -1617,6 +1752,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("immediate_clear", "immediate"), &VisualServer::immediate_clear);
ClassDB::bind_method(D_METHOD("immediate_set_material", "immediate", "material"), &VisualServer::immediate_set_material);
ClassDB::bind_method(D_METHOD("immediate_get_material", "immediate"), &VisualServer::immediate_get_material);
+#endif
ClassDB::bind_method(D_METHOD("skeleton_create"), &VisualServer::skeleton_create);
ClassDB::bind_method(D_METHOD("skeleton_allocate", "skeleton", "bones", "is_2d_skeleton"), &VisualServer::skeleton_allocate, DEFVAL(false));
@@ -1626,6 +1762,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform_2d);
ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform_2d);
+#ifndef _3D_DISABLED
ClassDB::bind_method(D_METHOD("directional_light_create"), &VisualServer::directional_light_create);
ClassDB::bind_method(D_METHOD("omni_light_create"), &VisualServer::omni_light_create);
ClassDB::bind_method(D_METHOD("spot_light_create"), &VisualServer::spot_light_create);
@@ -1695,7 +1832,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree", "capture"), &VisualServer::lightmap_capture_get_octree);
ClassDB::bind_method(D_METHOD("lightmap_capture_set_energy", "capture", "energy"), &VisualServer::lightmap_capture_set_energy);
ClassDB::bind_method(D_METHOD("lightmap_capture_get_energy", "capture"), &VisualServer::lightmap_capture_get_energy);
-
+#endif
ClassDB::bind_method(D_METHOD("particles_create"), &VisualServer::particles_create);
ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &VisualServer::particles_set_emitting);
ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &VisualServer::particles_get_emitting);
@@ -1782,6 +1919,8 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("scenario_set_reflection_atlas_size", "scenario", "p_size", "subdiv"), &VisualServer::scenario_set_reflection_atlas_size);
ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &VisualServer::scenario_set_fallback_environment);
+#ifndef _3D_DISABLED
+
ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &VisualServer::instance_create2);
ClassDB::bind_method(D_METHOD("instance_create"), &VisualServer::instance_create);
ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &VisualServer::instance_set_base);
@@ -1806,7 +1945,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &VisualServer::_instances_cull_aabb_bind, DEFVAL(RID()));
ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &VisualServer::_instances_cull_ray_bind, DEFVAL(RID()));
ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &VisualServer::_instances_cull_convex_bind, DEFVAL(RID()));
-
+#endif
ClassDB::bind_method(D_METHOD("canvas_create"), &VisualServer::canvas_create);
ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &VisualServer::canvas_set_item_mirroring);
ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &VisualServer::canvas_set_modulate);
@@ -1889,13 +2028,14 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("init"), &VisualServer::init);
ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish);
ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info);
+#ifndef _3D_DISABLED
+ ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh);
ClassDB::bind_method(D_METHOD("get_test_cube"), &VisualServer::get_test_cube);
+#endif
ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture);
ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture);
- ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh);
-
ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale"), &VisualServer::set_boot_image);
ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color);
@@ -2061,6 +2201,7 @@ void VisualServer::_bind_methods() {
BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);
BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_BAKED_LIGHT);
+ BIND_ENUM_CONSTANT(INSTANCE_FLAG_REDRAW_FRAME_IF_VISIBLE);
BIND_ENUM_CONSTANT(INSTANCE_FLAG_MAX);
BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 968cb852ed..367642b7d4 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -251,6 +251,10 @@ public:
virtual RID mesh_create() = 0;
+ virtual uint32_t mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const;
+ virtual uint32_t mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const;
+ /// Returns stride
+ virtual uint32_t mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const;
virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = ARRAY_COMPRESS_DEFAULT);
virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0;
@@ -805,6 +809,7 @@ public:
enum InstanceFlags {
INSTANCE_FLAG_USE_BAKED_LIGHT,
+ INSTANCE_FLAG_REDRAW_FRAME_IF_VISIBLE,
INSTANCE_FLAG_MAX
};