diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/arvr/arvr_interface.cpp | 6 | ||||
-rw-r--r-- | servers/arvr_server.cpp | 12 | ||||
-rw-r--r-- | servers/audio/audio_driver_dummy.cpp | 2 | ||||
-rw-r--r-- | servers/audio_server.cpp | 74 | ||||
-rw-r--r-- | servers/audio_server.h | 2 | ||||
-rw-r--r-- | servers/physics/broad_phase_octree.cpp | 1 | ||||
-rw-r--r-- | servers/physics/space_sw.cpp | 10 | ||||
-rw-r--r-- | servers/physics_2d/joints_2d_sw.cpp | 6 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 7 | ||||
-rw-r--r-- | servers/physics_2d_server.cpp | 158 | ||||
-rw-r--r-- | servers/physics_2d_server.h | 2 | ||||
-rw-r--r-- | servers/physics_server.cpp | 259 | ||||
-rw-r--r-- | servers/physics_server.h | 2 | ||||
-rw-r--r-- | servers/visual/rasterizer.h | 2 | ||||
-rw-r--r-- | servers/visual/shader_language.cpp | 14 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.cpp | 9 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.h | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 3 | ||||
-rw-r--r-- | servers/visual/visual_server_scene.cpp | 22 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 3 | ||||
-rw-r--r-- | servers/visual_server.cpp | 14 | ||||
-rw-r--r-- | servers/visual_server.h | 4 |
23 files changed, 339 insertions, 277 deletions
diff --git a/servers/arvr/arvr_interface.cpp b/servers/arvr/arvr_interface.cpp index 81eb011932..1f2e6028b0 100644 --- a/servers/arvr/arvr_interface.cpp +++ b/servers/arvr/arvr_interface.cpp @@ -51,9 +51,9 @@ void ARVRInterface::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "primary"), "set_is_primary", "is_primary"); - BIND_CONSTANT(EYE_MONO); - BIND_CONSTANT(EYE_LEFT); - BIND_CONSTANT(EYE_RIGHT); + BIND_ENUM_CONSTANT(EYE_MONO); + BIND_ENUM_CONSTANT(EYE_LEFT); + BIND_ENUM_CONSTANT(EYE_RIGHT); }; StringName ARVRInterface::get_name() const { diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index 6398d87007..8a064f9cce 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -58,12 +58,12 @@ void ARVRServer::_bind_methods() { ClassDB::bind_method(D_METHOD("add_interface"), &ARVRServer::add_interface); ClassDB::bind_method(D_METHOD("remove_interface"), &ARVRServer::remove_interface); - BIND_CONSTANT(TRACKER_CONTROLLER); - BIND_CONSTANT(TRACKER_BASESTATION); - BIND_CONSTANT(TRACKER_ANCHOR); - BIND_CONSTANT(TRACKER_UNKNOWN); - BIND_CONSTANT(TRACKER_ANY_KNOWN); - BIND_CONSTANT(TRACKER_ANY); + BIND_ENUM_CONSTANT(TRACKER_CONTROLLER); + BIND_ENUM_CONSTANT(TRACKER_BASESTATION); + BIND_ENUM_CONSTANT(TRACKER_ANCHOR); + BIND_ENUM_CONSTANT(TRACKER_UNKNOWN); + BIND_ENUM_CONSTANT(TRACKER_ANY_KNOWN); + BIND_ENUM_CONSTANT(TRACKER_ANY); ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING, "name"))); ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING, "name"))); diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 0f15b43b41..dfb6406b38 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -45,7 +45,7 @@ Error AudioDriverDummy::init() { channels = 2; int latency = GLOBAL_DEF("audio/output_latency", 25); - buffer_size = nearest_power_of_2(latency * mix_rate / 1000); + buffer_size = next_power_of_2(latency * mix_rate / 1000); samples_in = memnew_arr(int32_t, buffer_size * channels); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 3547f86eb3..f9fdd9432d 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -159,6 +159,8 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) { void AudioServer::_mix_step() { + bool solo_mode = false; + for (int i = 0; i < buses.size(); i++) { Bus *bus = buses[i]; bus->index_cache = i; //might be moved around by editor, so.. @@ -166,6 +168,33 @@ void AudioServer::_mix_step() { bus->channels[k].used = false; } + + if (bus->solo) { + //solo chain + solo_mode = true; + bus->soloed = true; + do { + + if (bus != buses[0]) { + //everything has a send save for master bus + if (!bus_map.has(bus->send)) { + bus = buses[0]; //send to master + } else { + bus = bus_map[bus->send]; + if (bus->index_cache >= bus->index_cache) { //invalid, send to master + bus = buses[0]; + } + } + + bus->soloed = true; + } else { + bus = NULL; + } + + } while (bus); + } else { + bus->soloed = false; + } } //make callbacks for mixing the audio @@ -192,24 +221,26 @@ void AudioServer::_mix_step() { } //process effects - for (int j = 0; j < bus->effects.size(); j++) { + if (!bus->bypass) { + for (int j = 0; j < bus->effects.size(); j++) { - if (!bus->effects[j].enabled) - continue; + if (!bus->effects[j].enabled) + continue; - for (int k = 0; k < bus->channels.size(); k++) { + for (int k = 0; k < bus->channels.size(); k++) { - if (!bus->channels[k].active) - continue; - bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size); - } + if (!bus->channels[k].active) + continue; + bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size); + } - //swap buffers, so internal buffer always has the right data - for (int k = 0; k < bus->channels.size(); k++) { + //swap buffers, so internal buffer always has the right data + for (int k = 0; k < bus->channels.size(); k++) { - if (!buses[i]->channels[k].active) - continue; - SWAP(bus->channels[k].buffer, temp_buffer[k]); + if (!buses[i]->channels[k].active) + continue; + SWAP(bus->channels[k].buffer, temp_buffer[k]); + } } } @@ -237,7 +268,24 @@ void AudioServer::_mix_step() { AudioFrame *buf = bus->channels[k].buffer.ptr(); AudioFrame peak = AudioFrame(0, 0); + + float volume = Math::db2linear(bus->volume_db); + + if (solo_mode) { + if (!bus->soloed) { + volume = 0.0; + } + } else { + if (bus->mute) { + volume = 0.0; + } + } + + //apply volume and compute peak for (uint32_t j = 0; j < buffer_size; j++) { + + buf[j] *= volume; + float l = ABS(buf[j].l); if (l > peak.l) { peak.l = l; diff --git a/servers/audio_server.h b/servers/audio_server.h index caa07891f7..c92ff6d3a0 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -125,6 +125,8 @@ private: bool mute; bool bypass; + bool soloed; + //Each channel is a stereo pair. struct Channel { bool used; diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp index e1aaf4e31a..fb2144bd03 100644 --- a/servers/physics/broad_phase_octree.cpp +++ b/servers/physics/broad_phase_octree.cpp @@ -124,6 +124,5 @@ BroadPhaseOctree::BroadPhaseOctree() { octree.set_unpair_callback(_unpair_callback, this); pair_callback = NULL; pair_userdata = NULL; - pair_callback = NULL; unpair_userdata = NULL; } diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 094cfa4656..fc52aa45aa 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -474,8 +474,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const { - CollisionObjectSW *obj = NULL; - obj = PhysicsServerSW::singleton->area_owner.getornull(p_object); + CollisionObjectSW *obj = PhysicsServerSW::singleton->area_owner.getornull(p_object); if (!obj) { obj = PhysicsServerSW::singleton->body_owner.getornull(p_object); } @@ -598,11 +597,8 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve cbk.amount = 0; cbk.ptr = sr; - CollisionSolverSW::CallbackResult cbkres = NULL; - - PhysicsServerSW::CollCbkData *cbkptr = NULL; - cbkptr = &cbk; - cbkres = PhysicsServerSW::_shape_col_cbk; + PhysicsServerSW::CollCbkData *cbkptr = &cbk; + CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk; bool collided = false; diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp index 449765621e..93091f55cf 100644 --- a/servers/physics_2d/joints_2d_sw.cpp +++ b/servers/physics_2d/joints_2d_sw.cpp @@ -408,8 +408,10 @@ bool GrooveJoint2DSW::setup(real_t p_step) { //joint->bias = cpvclamp(cpvmult(delta, -joint->constraint.biasCoef*dt_inv), joint->constraint.maxBias); Vector2 delta = (B->get_transform().get_origin() + rB) - (A->get_transform().get_origin() + rA); - real_t _b = get_bias(); - _b = 0.001; + + // FIXME: We used to do this assignment and then override it with 0.001 right after. Investigate why. + //real_t _b = get_bias(); + real_t _b = 0.001; gbias = (delta * -(_b == 0 ? space->get_constraint_bias() : _b) * (1.0 / p_step)).clamped(get_max_bias()); // apply accumulated impulse diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 29f879d8e9..718669988c 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -532,11 +532,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.amount = 0; cbk.ptr = sr; - CollisionSolver2DSW::CallbackResult cbkres = NULL; - - Physics2DServerSW::CollCbkData *cbkptr = NULL; - cbkptr = &cbk; - cbkres = Physics2DServerSW::_shape_col_cbk; + Physics2DServerSW::CollCbkData *cbkptr = &cbk; + CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk; bool collided = false; diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 27732b9c29..898c49a1eb 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -354,12 +354,12 @@ void Physics2DDirectSpaceState::_bind_methods() { ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &Physics2DDirectSpaceState::_get_rest_info); //ClassDB::bind_method(D_METHOD("cast_motion","shape","xform","motion","exclude","umask"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0)); - BIND_CONSTANT(TYPE_MASK_STATIC_BODY); - BIND_CONSTANT(TYPE_MASK_KINEMATIC_BODY); - BIND_CONSTANT(TYPE_MASK_RIGID_BODY); - BIND_CONSTANT(TYPE_MASK_CHARACTER_BODY); - BIND_CONSTANT(TYPE_MASK_AREA); - BIND_CONSTANT(TYPE_MASK_COLLISION); + BIND_ENUM_CONSTANT(TYPE_MASK_STATIC_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_KINEMATIC_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_RIGID_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_CHARACTER_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_AREA); + BIND_ENUM_CONSTANT(TYPE_MASK_COLLISION); } int Physics2DShapeQueryResult::get_result_count() const { @@ -604,79 +604,79 @@ void Physics2DServer::_bind_methods() { //ClassDB::bind_method(D_METHOD("sync"),&Physics2DServer::sync); //ClassDB::bind_method(D_METHOD("flush_queries"),&Physics2DServer::flush_queries); - BIND_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS); - BIND_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION); - BIND_CONSTANT(SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION); - BIND_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD); - BIND_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD); - BIND_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP); - BIND_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS); - - BIND_CONSTANT(SHAPE_LINE); - BIND_CONSTANT(SHAPE_SEGMENT); - BIND_CONSTANT(SHAPE_CIRCLE); - BIND_CONSTANT(SHAPE_RECTANGLE); - BIND_CONSTANT(SHAPE_CAPSULE); - BIND_CONSTANT(SHAPE_CONVEX_POLYGON); - BIND_CONSTANT(SHAPE_CONCAVE_POLYGON); - BIND_CONSTANT(SHAPE_CUSTOM); - - BIND_CONSTANT(AREA_PARAM_GRAVITY); - BIND_CONSTANT(AREA_PARAM_GRAVITY_VECTOR); - BIND_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT); - BIND_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE); - BIND_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION); - BIND_CONSTANT(AREA_PARAM_LINEAR_DAMP); - BIND_CONSTANT(AREA_PARAM_ANGULAR_DAMP); - BIND_CONSTANT(AREA_PARAM_PRIORITY); - - BIND_CONSTANT(AREA_SPACE_OVERRIDE_DISABLED); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE_REPLACE); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE_COMBINE); - - BIND_CONSTANT(BODY_MODE_STATIC); - BIND_CONSTANT(BODY_MODE_KINEMATIC); - BIND_CONSTANT(BODY_MODE_RIGID); - BIND_CONSTANT(BODY_MODE_CHARACTER); - - BIND_CONSTANT(BODY_PARAM_BOUNCE); - BIND_CONSTANT(BODY_PARAM_FRICTION); - BIND_CONSTANT(BODY_PARAM_MASS); - BIND_CONSTANT(BODY_PARAM_INERTIA); - BIND_CONSTANT(BODY_PARAM_GRAVITY_SCALE); - BIND_CONSTANT(BODY_PARAM_LINEAR_DAMP); - BIND_CONSTANT(BODY_PARAM_ANGULAR_DAMP); - BIND_CONSTANT(BODY_PARAM_MAX); - - BIND_CONSTANT(BODY_STATE_TRANSFORM); - BIND_CONSTANT(BODY_STATE_LINEAR_VELOCITY); - BIND_CONSTANT(BODY_STATE_ANGULAR_VELOCITY); - BIND_CONSTANT(BODY_STATE_SLEEPING); - BIND_CONSTANT(BODY_STATE_CAN_SLEEP); - - BIND_CONSTANT(JOINT_PIN); - BIND_CONSTANT(JOINT_GROOVE); - BIND_CONSTANT(JOINT_DAMPED_SPRING); - - BIND_CONSTANT(DAMPED_STRING_REST_LENGTH); - BIND_CONSTANT(DAMPED_STRING_STIFFNESS); - BIND_CONSTANT(DAMPED_STRING_DAMPING); - - BIND_CONSTANT(CCD_MODE_DISABLED); - BIND_CONSTANT(CCD_MODE_CAST_RAY); - BIND_CONSTANT(CCD_MODE_CAST_SHAPE); - - //BIND_CONSTANT( TYPE_BODY ); - //BIND_CONSTANT( TYPE_AREA ); - - BIND_CONSTANT(AREA_BODY_ADDED); - BIND_CONSTANT(AREA_BODY_REMOVED); - - BIND_CONSTANT(INFO_ACTIVE_OBJECTS); - BIND_CONSTANT(INFO_COLLISION_PAIRS); - BIND_CONSTANT(INFO_ISLAND_COUNT); + BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS); + BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION); + BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION); + BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD); + BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD); + BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP); + BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS); + + BIND_ENUM_CONSTANT(SHAPE_LINE); + BIND_ENUM_CONSTANT(SHAPE_SEGMENT); + BIND_ENUM_CONSTANT(SHAPE_CIRCLE); + BIND_ENUM_CONSTANT(SHAPE_RECTANGLE); + BIND_ENUM_CONSTANT(SHAPE_CAPSULE); + BIND_ENUM_CONSTANT(SHAPE_CONVEX_POLYGON); + BIND_ENUM_CONSTANT(SHAPE_CONCAVE_POLYGON); + BIND_ENUM_CONSTANT(SHAPE_CUSTOM); + + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION); + BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP); + BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP); + BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY); + + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_DISABLED); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE_REPLACE); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE_COMBINE); + + BIND_ENUM_CONSTANT(BODY_MODE_STATIC); + BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC); + BIND_ENUM_CONSTANT(BODY_MODE_RIGID); + BIND_ENUM_CONSTANT(BODY_MODE_CHARACTER); + + BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE); + BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION); + BIND_ENUM_CONSTANT(BODY_PARAM_MASS); + BIND_ENUM_CONSTANT(BODY_PARAM_INERTIA); + BIND_ENUM_CONSTANT(BODY_PARAM_GRAVITY_SCALE); + BIND_ENUM_CONSTANT(BODY_PARAM_LINEAR_DAMP); + BIND_ENUM_CONSTANT(BODY_PARAM_ANGULAR_DAMP); + BIND_ENUM_CONSTANT(BODY_PARAM_MAX); + + BIND_ENUM_CONSTANT(BODY_STATE_TRANSFORM); + BIND_ENUM_CONSTANT(BODY_STATE_LINEAR_VELOCITY); + BIND_ENUM_CONSTANT(BODY_STATE_ANGULAR_VELOCITY); + BIND_ENUM_CONSTANT(BODY_STATE_SLEEPING); + BIND_ENUM_CONSTANT(BODY_STATE_CAN_SLEEP); + + BIND_ENUM_CONSTANT(JOINT_PIN); + BIND_ENUM_CONSTANT(JOINT_GROOVE); + BIND_ENUM_CONSTANT(JOINT_DAMPED_SPRING); + + BIND_ENUM_CONSTANT(DAMPED_STRING_REST_LENGTH); + BIND_ENUM_CONSTANT(DAMPED_STRING_STIFFNESS); + BIND_ENUM_CONSTANT(DAMPED_STRING_DAMPING); + + BIND_ENUM_CONSTANT(CCD_MODE_DISABLED); + BIND_ENUM_CONSTANT(CCD_MODE_CAST_RAY); + BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE); + + //BIND_ENUM_CONSTANT( TYPE_BODY ); + //BIND_ENUM_CONSTANT( TYPE_AREA ); + + BIND_ENUM_CONSTANT(AREA_BODY_ADDED); + BIND_ENUM_CONSTANT(AREA_BODY_REMOVED); + + BIND_ENUM_CONSTANT(INFO_ACTIVE_OBJECTS); + BIND_ENUM_CONSTANT(INFO_COLLISION_PAIRS); + BIND_ENUM_CONSTANT(INFO_ISLAND_COUNT); } Physics2DServer::Physics2DServer() { diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index f3acd8df18..905f96a5a9 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -201,6 +201,8 @@ public: Physics2DDirectSpaceState(); }; +VARIANT_ENUM_CAST(Physics2DDirectSpaceState::ObjectTypeMask); + class Physics2DShapeQueryResult : public Reference { GDCLASS(Physics2DShapeQueryResult, Reference); diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index 86bf6253ee..c51a59973c 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -349,12 +349,12 @@ void PhysicsDirectSpaceState::_bind_methods() { ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_collide_shape, DEFVAL(32)); ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState::_get_rest_info); - BIND_CONSTANT(TYPE_MASK_STATIC_BODY); - BIND_CONSTANT(TYPE_MASK_KINEMATIC_BODY); - BIND_CONSTANT(TYPE_MASK_RIGID_BODY); - BIND_CONSTANT(TYPE_MASK_CHARACTER_BODY); - BIND_CONSTANT(TYPE_MASK_AREA); - BIND_CONSTANT(TYPE_MASK_COLLISION); + BIND_ENUM_CONSTANT(TYPE_MASK_STATIC_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_KINEMATIC_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_RIGID_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_CHARACTER_BODY); + BIND_ENUM_CONSTANT(TYPE_MASK_AREA); + BIND_ENUM_CONSTANT(TYPE_MASK_COLLISION); } int PhysicsShapeQueryResult::get_result_count() const { @@ -506,11 +506,11 @@ void PhysicsServer::_bind_methods() { /* JOINT API */ - BIND_CONSTANT(JOINT_PIN); - BIND_CONSTANT(JOINT_HINGE); - BIND_CONSTANT(JOINT_SLIDER); - BIND_CONSTANT(JOINT_CONE_TWIST); - BIND_CONSTANT(JOINT_6DOF); + BIND_ENUM_CONSTANT(JOINT_PIN); + BIND_ENUM_CONSTANT(JOINT_HINGE); + BIND_ENUM_CONSTANT(JOINT_SLIDER); + BIND_ENUM_CONSTANT(JOINT_CONE_TWIST); + BIND_ENUM_CONSTANT(JOINT_6DOF); ClassDB::bind_method(D_METHOD("joint_create_pin", "body_A", "local_A", "body_B", "local_B"), &PhysicsServer::joint_create_pin); ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer::pin_joint_set_param); @@ -522,20 +522,21 @@ void PhysicsServer::_bind_methods() { ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer::pin_joint_set_local_b); ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer::pin_joint_get_local_b); - BIND_CONSTANT(PIN_JOINT_BIAS); - BIND_CONSTANT(PIN_JOINT_DAMPING); - BIND_CONSTANT(PIN_JOINT_IMPULSE_CLAMP); - - BIND_CONSTANT(HINGE_JOINT_BIAS); - BIND_CONSTANT(HINGE_JOINT_LIMIT_UPPER); - BIND_CONSTANT(HINGE_JOINT_LIMIT_LOWER); - BIND_CONSTANT(HINGE_JOINT_LIMIT_BIAS); - BIND_CONSTANT(HINGE_JOINT_LIMIT_SOFTNESS); - BIND_CONSTANT(HINGE_JOINT_LIMIT_RELAXATION); - BIND_CONSTANT(HINGE_JOINT_MOTOR_TARGET_VELOCITY); - BIND_CONSTANT(HINGE_JOINT_MOTOR_MAX_IMPULSE); - BIND_CONSTANT(HINGE_JOINT_FLAG_USE_LIMIT); - BIND_CONSTANT(HINGE_JOINT_FLAG_ENABLE_MOTOR); + BIND_ENUM_CONSTANT(PIN_JOINT_BIAS); + BIND_ENUM_CONSTANT(PIN_JOINT_DAMPING); + BIND_ENUM_CONSTANT(PIN_JOINT_IMPULSE_CLAMP); + + BIND_ENUM_CONSTANT(HINGE_JOINT_BIAS); + BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_UPPER); + BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_LOWER); + BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_BIAS); + BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_SOFTNESS); + BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_RELAXATION); + BIND_ENUM_CONSTANT(HINGE_JOINT_MOTOR_TARGET_VELOCITY); + BIND_ENUM_CONSTANT(HINGE_JOINT_MOTOR_MAX_IMPULSE); + + BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_USE_LIMIT); + BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_ENABLE_MOTOR); ClassDB::bind_method(D_METHOD("joint_create_hinge", "body_A", "hinge_A", "body_B", "hinge_B"), &PhysicsServer::joint_create_hinge); @@ -550,60 +551,60 @@ void PhysicsServer::_bind_methods() { ClassDB::bind_method(D_METHOD("slider_joint_set_param", "joint", "param", "value"), &PhysicsServer::slider_joint_set_param); ClassDB::bind_method(D_METHOD("slider_joint_get_param", "joint", "param"), &PhysicsServer::slider_joint_get_param); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_UPPER); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_LOWER); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_DAMPING); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_SOFTNESS); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_RESTITUTION); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_DAMPING); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION); - BIND_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING); - - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_UPPER); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_LOWER); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_DAMPING); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_DAMPING); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION); - BIND_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING); - BIND_CONSTANT(SLIDER_JOINT_MAX); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_UPPER); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_LOWER); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_DAMPING); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_SOFTNESS); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_RESTITUTION); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_DAMPING); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION); + BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING); + + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_UPPER); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_LOWER); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_DAMPING); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_DAMPING); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION); + BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING); + BIND_ENUM_CONSTANT(SLIDER_JOINT_MAX); ClassDB::bind_method(D_METHOD("joint_create_cone_twist", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_cone_twist); ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param", "joint", "param", "value"), &PhysicsServer::cone_twist_joint_set_param); ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param", "joint", "param"), &PhysicsServer::cone_twist_joint_get_param); - BIND_CONSTANT(CONE_TWIST_JOINT_SWING_SPAN); - BIND_CONSTANT(CONE_TWIST_JOINT_TWIST_SPAN); - BIND_CONSTANT(CONE_TWIST_JOINT_BIAS); - BIND_CONSTANT(CONE_TWIST_JOINT_SOFTNESS); - BIND_CONSTANT(CONE_TWIST_JOINT_RELAXATION); - - BIND_CONSTANT(G6DOF_JOINT_LINEAR_LOWER_LIMIT); - BIND_CONSTANT(G6DOF_JOINT_LINEAR_UPPER_LIMIT); - BIND_CONSTANT(G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS); - BIND_CONSTANT(G6DOF_JOINT_LINEAR_RESTITUTION); - BIND_CONSTANT(G6DOF_JOINT_LINEAR_DAMPING); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_LOWER_LIMIT); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_UPPER_LIMIT); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_DAMPING); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_RESTITUTION); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_FORCE_LIMIT); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_ERP); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY); - BIND_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT); - - BIND_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT); - BIND_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT); - BIND_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_MOTOR); + BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SWING_SPAN); + BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_TWIST_SPAN); + BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_BIAS); + BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SOFTNESS); + BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_RELAXATION); + + BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_LOWER_LIMIT); + BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_UPPER_LIMIT); + BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS); + BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_RESTITUTION); + BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_DAMPING); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_LOWER_LIMIT); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_UPPER_LIMIT); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_DAMPING); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_RESTITUTION); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_FORCE_LIMIT); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_ERP); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY); + BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT); + + BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT); + BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT); + BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_MOTOR); ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer::joint_get_type); @@ -642,67 +643,67 @@ void PhysicsServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer::get_process_info); - BIND_CONSTANT(SHAPE_PLANE); - BIND_CONSTANT(SHAPE_RAY); - BIND_CONSTANT(SHAPE_SPHERE); - BIND_CONSTANT(SHAPE_BOX); - BIND_CONSTANT(SHAPE_CAPSULE); - BIND_CONSTANT(SHAPE_CONVEX_POLYGON); - BIND_CONSTANT(SHAPE_CONCAVE_POLYGON); - BIND_CONSTANT(SHAPE_HEIGHTMAP); - BIND_CONSTANT(SHAPE_CUSTOM); - - BIND_CONSTANT(AREA_PARAM_GRAVITY); - BIND_CONSTANT(AREA_PARAM_GRAVITY_VECTOR); - BIND_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT); - BIND_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE); - BIND_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION); - BIND_CONSTANT(AREA_PARAM_LINEAR_DAMP); - BIND_CONSTANT(AREA_PARAM_ANGULAR_DAMP); - BIND_CONSTANT(AREA_PARAM_PRIORITY); - - BIND_CONSTANT(AREA_SPACE_OVERRIDE_DISABLED); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE_REPLACE); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE); - BIND_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE_COMBINE); - - BIND_CONSTANT(BODY_MODE_STATIC); - BIND_CONSTANT(BODY_MODE_KINEMATIC); - BIND_CONSTANT(BODY_MODE_RIGID); - BIND_CONSTANT(BODY_MODE_CHARACTER); - - BIND_CONSTANT(BODY_PARAM_BOUNCE); - BIND_CONSTANT(BODY_PARAM_FRICTION); - BIND_CONSTANT(BODY_PARAM_MASS); - BIND_CONSTANT(BODY_PARAM_GRAVITY_SCALE); - BIND_CONSTANT(BODY_PARAM_ANGULAR_DAMP); - BIND_CONSTANT(BODY_PARAM_LINEAR_DAMP); - BIND_CONSTANT(BODY_PARAM_MAX); - - BIND_CONSTANT(BODY_STATE_TRANSFORM); - BIND_CONSTANT(BODY_STATE_LINEAR_VELOCITY); - BIND_CONSTANT(BODY_STATE_ANGULAR_VELOCITY); - BIND_CONSTANT(BODY_STATE_SLEEPING); - BIND_CONSTANT(BODY_STATE_CAN_SLEEP); + BIND_ENUM_CONSTANT(SHAPE_PLANE); + BIND_ENUM_CONSTANT(SHAPE_RAY); + BIND_ENUM_CONSTANT(SHAPE_SPHERE); + BIND_ENUM_CONSTANT(SHAPE_BOX); + BIND_ENUM_CONSTANT(SHAPE_CAPSULE); + BIND_ENUM_CONSTANT(SHAPE_CONVEX_POLYGON); + BIND_ENUM_CONSTANT(SHAPE_CONCAVE_POLYGON); + BIND_ENUM_CONSTANT(SHAPE_HEIGHTMAP); + BIND_ENUM_CONSTANT(SHAPE_CUSTOM); + + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE); + BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION); + BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP); + BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP); + BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY); + + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_DISABLED); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE_REPLACE); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE); + BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE_COMBINE); + + BIND_ENUM_CONSTANT(BODY_MODE_STATIC); + BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC); + BIND_ENUM_CONSTANT(BODY_MODE_RIGID); + BIND_ENUM_CONSTANT(BODY_MODE_CHARACTER); + + BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE); + BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION); + BIND_ENUM_CONSTANT(BODY_PARAM_MASS); + BIND_ENUM_CONSTANT(BODY_PARAM_GRAVITY_SCALE); + BIND_ENUM_CONSTANT(BODY_PARAM_ANGULAR_DAMP); + BIND_ENUM_CONSTANT(BODY_PARAM_LINEAR_DAMP); + BIND_ENUM_CONSTANT(BODY_PARAM_MAX); + + BIND_ENUM_CONSTANT(BODY_STATE_TRANSFORM); + BIND_ENUM_CONSTANT(BODY_STATE_LINEAR_VELOCITY); + BIND_ENUM_CONSTANT(BODY_STATE_ANGULAR_VELOCITY); + BIND_ENUM_CONSTANT(BODY_STATE_SLEEPING); + BIND_ENUM_CONSTANT(BODY_STATE_CAN_SLEEP); /* - BIND_CONSTANT( JOINT_PIN ); - BIND_CONSTANT( JOINT_GROOVE ); - BIND_CONSTANT( JOINT_DAMPED_SPRING ); + BIND_ENUM_CONSTANT( JOINT_PIN ); + BIND_ENUM_CONSTANT( JOINT_GROOVE ); + BIND_ENUM_CONSTANT( JOINT_DAMPED_SPRING ); - BIND_CONSTANT( DAMPED_STRING_REST_LENGTH ); - BIND_CONSTANT( DAMPED_STRING_STIFFNESS ); - BIND_CONSTANT( DAMPED_STRING_DAMPING ); + BIND_ENUM_CONSTANT( DAMPED_STRING_REST_LENGTH ); + BIND_ENUM_CONSTANT( DAMPED_STRING_STIFFNESS ); + BIND_ENUM_CONSTANT( DAMPED_STRING_DAMPING ); */ - //BIND_CONSTANT( TYPE_BODY ); - //BIND_CONSTANT( TYPE_AREA ); + //BIND_ENUM_CONSTANT( TYPE_BODY ); + //BIND_ENUM_CONSTANT( TYPE_AREA ); - BIND_CONSTANT(AREA_BODY_ADDED); - BIND_CONSTANT(AREA_BODY_REMOVED); + BIND_ENUM_CONSTANT(AREA_BODY_ADDED); + BIND_ENUM_CONSTANT(AREA_BODY_REMOVED); - BIND_CONSTANT(INFO_ACTIVE_OBJECTS); - BIND_CONSTANT(INFO_COLLISION_PAIRS); - BIND_CONSTANT(INFO_ISLAND_COUNT); + BIND_ENUM_CONSTANT(INFO_ACTIVE_OBJECTS); + BIND_ENUM_CONSTANT(INFO_COLLISION_PAIRS); + BIND_ENUM_CONSTANT(INFO_ISLAND_COUNT); } PhysicsServer::PhysicsServer() { diff --git a/servers/physics_server.h b/servers/physics_server.h index b38e14eb0c..a8c2a7761d 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -201,6 +201,8 @@ public: PhysicsDirectSpaceState(); }; +VARIANT_ENUM_CAST(PhysicsDirectSpaceState::ObjectTypeMask); + class PhysicsShapeQueryResult : public Reference { GDCLASS(PhysicsShapeQueryResult, Reference); diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 9405f6e012..3b4ba313e6 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -331,6 +331,7 @@ public: virtual void light_set_projector(RID p_light, RID p_texture) = 0; virtual void light_set_negative(RID p_light, bool p_enable) = 0; virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0; + virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0; virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) = 0; virtual void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) = 0; @@ -712,6 +713,7 @@ public: RID texture; RID normal_map; int count; + bool antialiased; CommandPolygon() { type = TYPE_POLYGON; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 49f9e161fa..3e0a1a6f45 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -1563,9 +1563,9 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { { "reflect", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, { "refract", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, - { "facefordward", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, - { "facefordward", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, - { "facefordward", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } }, + { "faceforward", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, + { "faceforward", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, + { "faceforward", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } }, { "matrixCompMult", TYPE_MAT2, { TYPE_MAT2, TYPE_MAT2, TYPE_VOID } }, { "matrixCompMult", TYPE_MAT3, { TYPE_MAT3, TYPE_MAT3, TYPE_VOID } }, @@ -1931,7 +1931,8 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p } if (!fail) { - p_func->return_cache = pfunc->return_type; + if (r_ret_type) + *r_ret_type = pfunc->return_type; return true; } } @@ -3150,6 +3151,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Dat assign->op = OP_ASSIGN; p_block->statements.push_back(assign); tk = _get_token(); + + if (!_validate_operator(assign)) { + _set_error("Invalid assignment of '" + get_datatype_name(n->get_datatype()) + "' to '" + get_datatype_name(type) + "'"); + return ERR_PARSE_ERROR; + } } if (tk.type == TK_COMMA) { diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index dcc16794e7..13517fa409 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -632,7 +632,7 @@ void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Poin canvas_item->commands.push_back(prim); } -void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map) { +void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, bool p_antialiased) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -661,6 +661,7 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2 polygon->colors = p_colors; polygon->indices = indices; polygon->count = indices.size(); + polygon->antialiased = p_antialiased; canvas_item->rect_dirty = true; canvas_item->commands.push_back(polygon); @@ -745,6 +746,7 @@ void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, //take the chance and request processing for them, at least once until they become visible again VSG::storage->particles_request_process(p_particles); + canvas_item->rect_dirty = true; canvas_item->commands.push_back(part); } @@ -758,6 +760,7 @@ void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p mm->multimesh = p_mesh; mm->skeleton = p_skeleton; + canvas_item->rect_dirty = true; canvas_item->commands.push_back(mm); } @@ -1001,11 +1004,11 @@ void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_ RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light); ERR_FAIL_COND(!clight); - int new_size = nearest_power_of_2(p_size); + int new_size = next_power_of_2(p_size); if (new_size == clight->shadow_buffer_size) return; - clight->shadow_buffer_size = nearest_power_of_2(p_size); + clight->shadow_buffer_size = next_power_of_2(p_size); if (clight->shadow_buffer.is_valid()) { VSG::storage->free(clight->shadow_buffer); diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 25d4973cb7..b9ad88286d 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -178,7 +178,7 @@ public: void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = true); void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()); void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()); - void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID()); + void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false); void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()); void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID()); void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID()); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 4f16ae4125..e66c8a1e21 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -4376,7 +4376,7 @@ void VisualServerRaster::canvas_light_set_shadow_buffer_size(RID p_light, int p_ ERR_FAIL_COND(p_size<32 || p_size>16384); - clight->shadow_buffer_size=nearest_power_of_2(p_size); + clight->shadow_buffer_size=next_power_of_2(p_size); if (clight->shadow_buffer.is_valid()) { diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 596dd5c10e..fff37a71b3 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -786,6 +786,7 @@ public: BIND2(light_set_projector, RID, RID) BIND2(light_set_negative, RID, bool) BIND2(light_set_cull_mask, RID, uint32_t) + BIND2(light_set_reverse_cull_face_mode, RID, bool) BIND2(light_omni_set_shadow_mode, RID, LightOmniShadowMode) BIND2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail) @@ -1059,7 +1060,7 @@ public: BIND8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool) BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID) BIND7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID) - BIND6(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID) + BIND7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool) BIND8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID) BIND3(canvas_item_add_mesh, RID, const RID &, RID) BIND3(canvas_item_add_multimesh, RID, RID, RID) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 5faf0e67ca..fb298e3ed7 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -978,16 +978,6 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF switch (p_flags) { - case VS::INSTANCE_FLAG_CAST_SHADOW: { - if (p_enabled == true) { - instance->cast_shadows = VS::SHADOW_CASTING_SETTING_ON; - } else { - instance->cast_shadows = VS::SHADOW_CASTING_SETTING_OFF; - } - - instance->base_material_changed(); // to actually compute if shadows are visible or not - - } break; case VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS: { instance->visible_in_all_rooms = p_enabled; @@ -1001,6 +991,12 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF } } void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) { + + Instance *instance = instance_owner.get(p_instance); + ERR_FAIL_COND(!instance); + + instance->cast_shadows = p_shadow_casting_setting; + instance->base_material_changed(); // to actually compute if shadows are visible or not } void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) { @@ -1048,8 +1044,9 @@ void VisualServerScene::_update_instance(Instance *p_instance) { VSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform); } - if (p_instance->aabb.has_no_surface()) + if (p_instance->aabb.has_no_surface()) { return; + } #if 0 if (p_instance->base_type == VS::INSTANCE_PARTICLES) { @@ -3278,8 +3275,9 @@ void VisualServerScene::render_probes() { void VisualServerScene::_update_dirty_instance(Instance *p_instance) { - if (p_instance->update_aabb) + if (p_instance->update_aabb) { _update_instance_aabb(p_instance); + } if (p_instance->update_materials) { diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 20223f9651..ca040e9355 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -225,6 +225,7 @@ public: FUNC2(light_set_projector, RID, RID) FUNC2(light_set_negative, RID, bool) FUNC2(light_set_cull_mask, RID, uint32_t) + FUNC2(light_set_reverse_cull_face_mode, RID, bool) FUNC2(light_omni_set_shadow_mode, RID, LightOmniShadowMode) FUNC2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail) @@ -482,7 +483,7 @@ public: FUNC8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool) FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID) FUNC7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID) - FUNC6(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID) + FUNC7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool) FUNC8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID) FUNC3(canvas_item_add_mesh, RID, const RID &, RID) FUNC3(canvas_item_add_multimesh, RID, RID, RID) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 65dd4d7661..cb1f96c23f 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -298,6 +298,9 @@ RID VisualServer::get_white_texture() { return white_texture; } +#define SMALL_VEC2 Vector2(0.00001, 0.00001) +#define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001) + Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb) { PoolVector<uint8_t>::Write vw = r_vertex_array.write(); @@ -339,7 +342,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect2(src[i], Vector2()); + aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size } else { aabb.expand_to(src[i]); @@ -355,7 +358,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect2(src[i], Vector2()); + aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size } else { aabb.expand_to(src[i]); @@ -385,7 +388,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], Vector3()); + aabb = Rect3(src[i], SMALL_VEC3); } else { aabb.expand_to(src[i]); @@ -401,7 +404,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], Vector3()); + aabb = Rect3(src[i], SMALL_VEC3); } else { aabb.expand_to(src[i]); @@ -733,8 +736,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (bptr->size.x < 0) { //first - bptr[idx] = Rect3(); - bptr[idx].position = v; + bptr[idx] = Rect3(v, SMALL_VEC3); any_valid = true; } else { bptr[idx].expand_to(v); diff --git a/servers/visual_server.h b/servers/visual_server.h index ddf32a9ea1..5e0a390a21 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -371,6 +371,7 @@ public: virtual void light_set_projector(RID p_light, RID p_texture) = 0; virtual void light_set_negative(RID p_light, bool p_enable) = 0; virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0; + virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0; // omni light enum LightOmniShadowMode { @@ -743,7 +744,6 @@ public: virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0; enum InstanceFlags { - INSTANCE_FLAG_CAST_SHADOW, INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, INSTANCE_FLAG_USE_BAKED_LIGHT, INSTANCE_FLAG_MAX @@ -798,7 +798,7 @@ public: virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = true) = 0; virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0; virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0; - virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID()) = 0; + virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0; virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()) = 0; virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID()) = 0; virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID()) = 0; |