diff options
Diffstat (limited to 'servers')
| -rw-r--r-- | servers/arvr/arvr_positional_tracker.cpp | 23 | ||||
| -rw-r--r-- | servers/arvr_server.cpp | 21 | ||||
| -rw-r--r-- | servers/arvr_server.h | 14 | ||||
| -rw-r--r-- | servers/audio_server.cpp | 8 | ||||
| -rw-r--r-- | servers/physics_2d_server.cpp | 4 | ||||
| -rw-r--r-- | servers/visual/rasterizer.h | 2 | ||||
| -rw-r--r-- | servers/visual/shader_language.cpp | 1 | ||||
| -rw-r--r-- | servers/visual/shader_types.cpp | 1 | ||||
| -rw-r--r-- | servers/visual/visual_server_raster.h | 1 | ||||
| -rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 1 | ||||
| -rw-r--r-- | servers/visual_server.h | 1 |
11 files changed, 60 insertions, 17 deletions
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp index fc0270615c..fb97d5b86b 100644 --- a/servers/arvr/arvr_positional_tracker.cpp +++ b/servers/arvr/arvr_positional_tracker.cpp @@ -62,13 +62,15 @@ void ARVRPositionalTracker::_bind_methods() { void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) { if (type != p_type) { type = p_type; + hand = ARVRPositionalTracker::TRACKER_HAND_UNKNOWN; ARVRServer *arvr_server = ARVRServer::get_singleton(); ERR_FAIL_NULL(arvr_server); // get a tracker id for our type + // note if this is a controller this will be 3 or higher but we may change it later. tracker_id = arvr_server->get_free_tracker_id_for_type(p_type); - } + }; }; ARVRServer::TrackerType ARVRPositionalTracker::get_type() const { @@ -156,7 +158,24 @@ ARVRPositionalTracker::TrackerHand ARVRPositionalTracker::get_hand() const { }; void ARVRPositionalTracker::set_hand(const ARVRPositionalTracker::TrackerHand p_hand) { - hand = p_hand; + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL(arvr_server); + + if (hand != p_hand) { + // we can only set this if we've previously set this to be a controller!! + ERR_FAIL_COND((type != ARVRServer::TRACKER_CONTROLLER) && (p_hand != ARVRPositionalTracker::TRACKER_HAND_UNKNOWN)); + + hand = p_hand; + if (hand == ARVRPositionalTracker::TRACKER_LEFT_HAND) { + if (!arvr_server->is_tracker_id_in_use_for_type(type, 1)) { + tracker_id = 1; + }; + } else if (hand == ARVRPositionalTracker::TRACKER_RIGHT_HAND) { + if (!arvr_server->is_tracker_id_in_use_for_type(type, 2)) { + tracker_id = 2; + }; + }; + }; }; Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const { diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index 1e73d6753c..df73040e1e 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -43,7 +43,7 @@ void ARVRServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVRServer::get_world_scale); ClassDB::bind_method(D_METHOD("set_world_scale"), &ARVRServer::set_world_scale); ClassDB::bind_method(D_METHOD("get_reference_frame"), &ARVRServer::get_reference_frame); - ClassDB::bind_method(D_METHOD("center_on_hmd", "ignore_tilt", "keep_height"), &ARVRServer::center_on_hmd); + ClassDB::bind_method(D_METHOD("center_on_hmd", "rotation_mode", "keep_height"), &ARVRServer::center_on_hmd); ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale"); @@ -63,6 +63,10 @@ void ARVRServer::_bind_methods() { BIND_ENUM_CONSTANT(TRACKER_UNKNOWN); BIND_ENUM_CONSTANT(TRACKER_ANY); + BIND_ENUM_CONSTANT(RESET_FULL_ROTATION); + BIND_ENUM_CONSTANT(RESET_BUT_KEEP_TILT); + BIND_ENUM_CONSTANT(DONT_RESET_ROTATION); + ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING, "name"))); ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING, "name"))); @@ -96,7 +100,7 @@ Transform ARVRServer::get_reference_frame() const { return reference_frame; }; -void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) { +void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) { if (primary_interface != NULL) { // clear our current reference frame or we'll end up double adjusting it reference_frame = Transform(); @@ -105,7 +109,7 @@ void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) { Transform new_reference_frame = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform()); // remove our tilt - if (p_ignore_tilt) { + if (p_rotation_mode == 1) { // take the Y out of our Z new_reference_frame.basis.set_axis(2, Vector3(new_reference_frame.basis.elements[0][2], 0.0, new_reference_frame.basis.elements[2][2]).normalized()); @@ -114,6 +118,9 @@ void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) { // and X is our cross reference new_reference_frame.basis.set_axis(0, new_reference_frame.basis.get_axis(1).cross(new_reference_frame.basis.get_axis(2)).normalized()); + } else if (p_rotation_mode == 2) { + // remove our rotation, we're only interesting in centering on position + new_reference_frame.basis = Basis(); }; // don't negate our height @@ -229,8 +236,12 @@ bool ARVRServer::is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p }; int ARVRServer::get_free_tracker_id_for_type(TrackerType p_tracker_type) { - // we start checking at 1, 0 means that it's not a controller.. - int tracker_id = 1; + // We start checking at 1, 0 means that it's not a controller.. + // Note that for controller we reserve: + // - 1 for the left hand controller and + // - 2 for the right hand controller + // so we start at 3 :) + int tracker_id = p_tracker_type == ARVRServer::TRACKER_CONTROLLER ? 3 : 1; while (is_tracker_id_in_use_for_type(p_tracker_type, tracker_id)) { // try the next one diff --git a/servers/arvr_server.h b/servers/arvr_server.h index 9b84ee2e99..0381e6e533 100644 --- a/servers/arvr_server.h +++ b/servers/arvr_server.h @@ -68,6 +68,12 @@ public: TRACKER_ANY = 0xff /* used by get_connected_trackers to return all types */ }; + enum RotationMode { + RESET_FULL_ROTATION = 0, /* we reset the full rotation, regardless of how the HMD is oriented, we're looking dead ahead */ + RESET_BUT_KEEP_TILT = 1, /* reset rotation but keep tilt. */ + DONT_RESET_ROTATION = 2, /* don't reset the rotation, we will only center on position */ + }; + private: Vector<Ref<ARVRInterface> > interfaces; Vector<ARVRPositionalTracker *> trackers; @@ -78,8 +84,6 @@ private: Transform world_origin; /* our world origin point, maps a location in our virtual world to the origin point in our real world tracking volume */ Transform reference_frame; /* our reference frame */ - bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const; - protected: static ARVRServer *singleton; @@ -127,7 +131,7 @@ public: and in the virtual world out of sync */ Transform get_reference_frame() const; - void center_on_hmd(bool p_ignore_tilt, bool p_keep_height); + void center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height); /* Interfaces are objects that 'glue' Godot to an AR or VR SDK such as the Oculus SDK, OpenVR, OpenHMD, etc. @@ -150,9 +154,8 @@ public: /* Our trackers are objects that expose the orientation and position of physical devices such as controller, anchor points, etc. They are created and managed by our active AR/VR interfaces. - - Note that for trackers that */ + bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const; int get_free_tracker_id_for_type(TrackerType p_tracker_type); void add_tracker(ARVRPositionalTracker *p_tracker); void remove_tracker(ARVRPositionalTracker *p_tracker); @@ -167,5 +170,6 @@ public: #define ARVR ARVRServer VARIANT_ENUM_CAST(ARVRServer::TrackerType); +VARIANT_ENUM_CAST(ARVRServer::RotationMode); #endif diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index a08733de87..8b14a5a8a7 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -892,15 +892,15 @@ void AudioServer::load_default_bus_layout() { void AudioServer::finish() { + for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) { + AudioDriverManager::get_driver(i)->finish(); + } + for (int i = 0; i < buses.size(); i++) { memdelete(buses[i]); } buses.clear(); - - for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) { - AudioDriverManager::get_driver(i)->finish(); - } } void AudioServer::update() { diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index dc58cd36dd..dad4711c07 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -654,6 +654,10 @@ void Physics2DServer::_bind_methods() { BIND_ENUM_CONSTANT(JOINT_GROOVE); BIND_ENUM_CONSTANT(JOINT_DAMPED_SPRING); + BIND_ENUM_CONSTANT(JOINT_PARAM_BIAS); + BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_BIAS); + BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_FORCE); + BIND_ENUM_CONSTANT(DAMPED_STRING_REST_LENGTH); BIND_ENUM_CONSTANT(DAMPED_STRING_STIFFNESS); BIND_ENUM_CONSTANT(DAMPED_STRING_DAMPING); diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index c5c225a40a..667a0f5742 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -473,6 +473,8 @@ public: virtual RID particles_create() = 0; virtual void particles_set_emitting(RID p_particles, bool p_emitting) = 0; + virtual bool particles_get_emitting(RID p_particles) = 0; + virtual void particles_set_amount(RID p_particles, int p_amount) = 0; virtual void particles_set_lifetime(RID p_particles, float p_lifetime) = 0; virtual void particles_set_one_shot(RID p_particles, bool p_one_shot) = 0; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 834505df9a..076f337635 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -334,6 +334,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { while (true) { if (GETCHAR(0) == '\n') { + tk_line++; char_idx++; break; } diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index a25c5ca65e..96f981ab5e 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -109,7 +109,6 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SIDE"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA_SCISSOR"] = ShaderLanguage::TYPE_FLOAT; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 716c1754e1..9b19aa0eff 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -384,6 +384,7 @@ public: BIND0R(RID, particles_create) BIND2(particles_set_emitting, RID, bool) + BIND1R(bool, particles_get_emitting, RID) BIND2(particles_set_amount, RID, int) BIND2(particles_set_lifetime, RID, float) BIND2(particles_set_one_shot, RID, bool) diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 0f24521f5d..a350cc1809 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -317,6 +317,7 @@ public: FUNCRID(particles) FUNC2(particles_set_emitting, RID, bool) + FUNC1R(bool, particles_get_emitting, RID) FUNC2(particles_set_amount, RID, int) FUNC2(particles_set_lifetime, RID, float) FUNC2(particles_set_one_shot, RID, bool) diff --git a/servers/visual_server.h b/servers/visual_server.h index 23354c3d37..e45b18b066 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -504,6 +504,7 @@ public: virtual RID particles_create() = 0; virtual void particles_set_emitting(RID p_particles, bool p_emitting) = 0; + virtual bool particles_get_emitting(RID p_particles) = 0; virtual void particles_set_amount(RID p_particles, int p_amount) = 0; virtual void particles_set_lifetime(RID p_particles, float p_lifetime) = 0; virtual void particles_set_one_shot(RID p_particles, bool p_one_shot) = 0; |