diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/area.cpp | 4 | ||||
-rw-r--r-- | scene/3d/arvr_nodes.cpp | 113 | ||||
-rw-r--r-- | scene/3d/arvr_nodes.h | 37 | ||||
-rw-r--r-- | scene/3d/collision_object.cpp | 4 | ||||
-rw-r--r-- | scene/3d/physics_body.cpp | 31 | ||||
-rw-r--r-- | scene/3d/physics_body.h | 2 | ||||
-rw-r--r-- | scene/3d/physics_joint.cpp | 26 | ||||
-rw-r--r-- | scene/3d/physics_joint.h | 8 | ||||
-rw-r--r-- | scene/3d/remote_transform.cpp | 2 | ||||
-rw-r--r-- | scene/3d/skeleton.cpp | 4 | ||||
-rw-r--r-- | scene/3d/sprite_3d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/visibility_notifier.cpp | 2 | ||||
-rw-r--r-- | scene/3d/visual_instance.cpp | 2 |
13 files changed, 209 insertions, 30 deletions
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 59227070b3..c64b807e43 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -475,7 +475,7 @@ Array Area::get_overlapping_areas() const { bool Area::overlaps_area(Node *p_area) const { ERR_FAIL_NULL_V(p_area, false); - const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_ID()); + const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id()); if (!E) return false; return E->get().in_tree; @@ -484,7 +484,7 @@ bool Area::overlaps_area(Node *p_area) const { bool Area::overlaps_body(Node *p_body) const { ERR_FAIL_NULL_V(p_body, false); - const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_ID()); + const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id()); if (!E) return false; return E->get().in_tree; diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index 5f2a720748..3c99f7fb3a 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -98,6 +98,7 @@ void ARVRController::_notification(int p_what) { is_active = false; button_states = 0; } else { + is_active = true; set_transform(tracker->get_transform(true)); int joy_id = tracker->get_joy_id(); @@ -231,6 +232,118 @@ ARVRController::~ARVRController(){ //////////////////////////////////////////////////////////////////////////////////////////////////// +void ARVRAnchor::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + set_process_internal(true); + }; break; + case NOTIFICATION_EXIT_TREE: { + set_process_internal(false); + }; break; + case NOTIFICATION_INTERNAL_PROCESS: { + // get our ARVRServer + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL(arvr_server); + + // find the tracker for our anchor + ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id); + if (tracker == NULL) { + // this anchor is currently not available + is_active = false; + } else { + is_active = true; + Transform transform; + + // we'll need our world_scale + real_t world_scale = arvr_server->get_world_scale(); + + // get our info from our tracker + transform.basis = tracker->get_orientation(); + transform.origin = tracker->get_position(); // <-- already adjusted to world scale + + // our basis is scaled to the size of the plane the anchor is tracking + // extract the size from our basis and reset the scale + size = transform.basis.get_scale() * world_scale; + transform.basis.set_scale(Vector3(1.0, 1.0, 1.0)); + + // apply our reference frame and set our transform + set_transform(arvr_server->get_reference_frame() * transform); + }; + }; break; + default: + break; + }; +}; + +void ARVRAnchor::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &ARVRAnchor::set_anchor_id); + ClassDB::bind_method(D_METHOD("get_anchor_id"), &ARVRAnchor::get_anchor_id); + ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id"), "set_anchor_id", "get_anchor_id"); + ClassDB::bind_method(D_METHOD("get_anchor_name"), &ARVRAnchor::get_anchor_name); + + ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active); + ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size); +}; + +void ARVRAnchor::set_anchor_id(int p_anchor_id) { + // we don't check any bounds here, this anchor may not yet be active and just be a place holder until it is. + anchor_id = p_anchor_id; +}; + +int ARVRAnchor::get_anchor_id(void) const { + return anchor_id; +}; + +Vector3 ARVRAnchor::get_size() const { + return size; +}; + +String ARVRAnchor::get_anchor_name(void) const { + // get our ARVRServer + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL_V(arvr_server, String()); + + ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id); + if (tracker == NULL) { + return String("Not connected"); + }; + + return tracker->get_name(); +}; + +bool ARVRAnchor::get_is_active() const { + return is_active; +}; + +String ARVRAnchor::get_configuration_warning() const { + if (!is_visible() || !is_inside_tree()) + return String(); + + // must be child node of ARVROrigin! + ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>(); + if (origin == NULL) { + return TTR("ARVRAnchor must have an ARVROrigin node as its parent"); + }; + + if (anchor_id == 0) { + return TTR("The anchor id must not be 0 or this anchor will not be bound to an actual anchor"); + }; + + return String(); +}; + +ARVRAnchor::ARVRAnchor() { + anchor_id = 0; + is_active = true; +}; + +ARVRAnchor::~ARVRAnchor(){ + // nothing to do here yet for now.. +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////// + String ARVROrigin::get_configuration_warning() const { if (!is_visible() || !is_inside_tree()) return String(); diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h index 3dab263317..936519126b 100644 --- a/scene/3d/arvr_nodes.h +++ b/scene/3d/arvr_nodes.h @@ -39,7 +39,7 @@ **/ /* - ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned + ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned */ class ARVRCamera : public Camera { @@ -56,9 +56,9 @@ public: }; /* - ARVRController is a helper node that automatically updates it's position based on tracker data. + ARVRController is a helper node that automatically updates it's position based on tracker data. - It must be a child node of our ARVROrigin node + It must be a child node of our ARVROrigin node */ class ARVRController : public Spatial { @@ -92,6 +92,37 @@ public: }; /* + ARVRAnchor is a helper node that automatically updates it's position based on anchor data, it represents a real world location. + It must be a child node of our ARVROrigin node +*/ + +class ARVRAnchor : public Spatial { + GDCLASS(ARVRAnchor, Spatial); + +private: + int anchor_id; + bool is_active; + Vector3 size; + +protected: + void _notification(int p_what); + static void _bind_methods(); + +public: + void set_anchor_id(int p_anchor_id); + int get_anchor_id(void) const; + String get_anchor_name(void) const; + + bool get_is_active() const; + Vector3 get_size() const; + + String get_configuration_warning() const; + + ARVRAnchor(); + ~ARVRAnchor(); +}; + +/* ARVROrigin is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world. It is this point that you will move around the world as the player 'moves while standing still', i.e. the player moves through teleporting or controller inputs as opposed to physically moving. diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 5a3d8e013f..2686cd81df 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -346,9 +346,9 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) { total_subshapes = 0; if (p_area) { - PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid, get_instance_ID()); + PhysicsServer::get_singleton()->area_attach_object_instance_id(rid, get_instance_id()); } else { - PhysicsServer::get_singleton()->body_attach_object_instance_ID(rid, get_instance_ID()); + PhysicsServer::get_singleton()->body_attach_object_instance_id(rid, get_instance_id()); } //set_transform_notify(true); } diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 7e599ce2f5..9feed2fe7b 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -473,6 +473,21 @@ void RigidBody::_direct_state_changed(Object *p_state) { } void RigidBody::_notification(int p_what) { + +#ifdef TOOLS_ENABLED + if (p_what == NOTIFICATION_ENTER_TREE) { + if (get_tree()->is_editor_hint()) { + set_notify_local_transform(true); //used for warnings and only in editor + } + } + + if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { + if (get_tree()->is_editor_hint()) { + update_configuration_warning(); + } + } + +#endif } void RigidBody::set_mode(Mode p_mode) { @@ -747,6 +762,22 @@ Array RigidBody::get_colliding_bodies() const { return ret; } +String RigidBody::get_configuration_warning() const { + + Transform t = get_transform(); + + String warning = CollisionObject::get_configuration_warning(); + + if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(0).length() - 1.0) > 0.05)) { + if (warning != String()) { + warning += "\n"; + } + warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead."); + } + + return warning; +} + void RigidBody::_bind_methods() { ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody::set_mode); diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index f86d7d957f..83811a1d93 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -252,6 +252,8 @@ public: void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse); + virtual String get_configuration_warning() const; + RigidBody(); ~RigidBody(); }; diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index 3fb5c828c2..61d496935b 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -979,9 +979,9 @@ Generic6DOFJoint::Generic6DOFJoint() { void PhysicsJoint::_set(const String& p_name, const Variant& p_value) { if (p_name=="body_A") - set_body_A(p_value); + set_body_a(p_value); else if (p_name=="body_B") - set_body_B(p_value); + set_body_b(p_value); else if (p_name=="active") set_active(p_value); else if (p_name=="no_collision") @@ -990,9 +990,9 @@ void PhysicsJoint::_set(const String& p_name, const Variant& p_value) { Variant PhysicsJoint::_get(const String& p_name) const { if (p_name=="body_A") - return get_body_A(); + return get_body_a(); else if (p_name=="body_B") - return get_body_B(); + return get_body_b(); else if (p_name=="active") return is_active(); else if (p_name=="no_collision") @@ -1034,7 +1034,7 @@ void PhysicsJoint::_notification(int p_what) { if (indicator.is_valid()) { indicator_instance=VisualServer::get_singleton()->instance_create(indicator,get_world()->get_scenario()); - VisualServer::get_singleton()->instance_attach_object_instance_ID( indicator_instance,get_instance_ID() ); + VisualServer::get_singleton()->instance_attach_object_instance_id( indicator_instance,get_instance_id() ); } } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -1067,10 +1067,10 @@ RID PhysicsJoint::_get_visual_instance_rid() const { void PhysicsJoint::_bind_methods() { ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid); - ClassDB::bind_method(D_METHOD("set_body_A","path"),&PhysicsJoint::set_body_A); - ClassDB::bind_method(D_METHOD("set_body_B"),&PhysicsJoint::set_body_B); - ClassDB::bind_method(D_METHOD("get_body_A","path"),&PhysicsJoint::get_body_A); - ClassDB::bind_method(D_METHOD("get_body_B"),&PhysicsJoint::get_body_B); + ClassDB::bind_method(D_METHOD("set_body_a","path"),&PhysicsJoint::set_body_a); + ClassDB::bind_method(D_METHOD("set_body_b"),&PhysicsJoint::set_body_b); + ClassDB::bind_method(D_METHOD("get_body_a","path"),&PhysicsJoint::get_body_a); + ClassDB::bind_method(D_METHOD("get_body_b"),&PhysicsJoint::get_body_b); ClassDB::bind_method(D_METHOD("set_active","active"),&PhysicsJoint::set_active); ClassDB::bind_method(D_METHOD("is_active"),&PhysicsJoint::is_active); @@ -1085,14 +1085,14 @@ void PhysicsJoint::_bind_methods() { } -void PhysicsJoint::set_body_A(const NodePath& p_path) { +void PhysicsJoint::set_body_a(const NodePath& p_path) { _disconnect(); body_A=p_path; _connect(); _change_notify("body_A"); } -void PhysicsJoint::set_body_B(const NodePath& p_path) { +void PhysicsJoint::set_body_b(const NodePath& p_path) { _disconnect(); body_B=p_path; @@ -1100,11 +1100,11 @@ void PhysicsJoint::set_body_B(const NodePath& p_path) { _change_notify("body_B"); } -NodePath PhysicsJoint::get_body_A() const { +NodePath PhysicsJoint::get_body_a() const { return body_A; } -NodePath PhysicsJoint::get_body_B() const { +NodePath PhysicsJoint::get_body_b() const { return body_B; } diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h index 2b221e25f2..b834aaf6d2 100644 --- a/scene/3d/physics_joint.h +++ b/scene/3d/physics_joint.h @@ -354,10 +354,10 @@ protected: void _connect(); public: - void set_body_A(const NodePath& p_path); - void set_body_B(const NodePath& p_path); - NodePath get_body_A() const; - NodePath get_body_B() const; + void set_body_a(const NodePath& p_path); + void set_body_b(const NodePath& p_path); + NodePath get_body_a() const; + NodePath get_body_b() const; void set_active(bool p_active); bool is_active() const; diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp index 4dcfb5f94e..492930ea9b 100644 --- a/scene/3d/remote_transform.cpp +++ b/scene/3d/remote_transform.cpp @@ -39,7 +39,7 @@ void RemoteTransform::_update_cache() { return; } - cache = node->get_instance_ID(); + cache = node->get_instance_id(); } } diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 71af77c027..ea5d21cd4e 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -407,7 +407,7 @@ void Skeleton::bind_child_node_to_bone(int p_bone, Node *p_node) { ERR_FAIL_NULL(p_node); ERR_FAIL_INDEX(p_bone, bones.size()); - uint32_t id = p_node->get_instance_ID(); + uint32_t id = p_node->get_instance_id(); for (List<uint32_t>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) { @@ -422,7 +422,7 @@ void Skeleton::unbind_child_node_from_bone(int p_bone, Node *p_node) { ERR_FAIL_NULL(p_node); ERR_FAIL_INDEX(p_bone, bones.size()); - uint32_t id = p_node->get_instance_ID(); + uint32_t id = p_node->get_instance_id(); bones[p_bone].nodes_bound.erase(id); } void Skeleton::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const { diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 78e8e92afc..1b9b58ceb1 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -502,7 +502,7 @@ void Sprite3D::set_vframes(int p_amount) { ERR_FAIL_COND(p_amount < 1); vframes = p_amount; _queue_update(); - _change_notify("frame"); + _change_notify(); } int Sprite3D::get_vframes() const { @@ -514,7 +514,7 @@ void Sprite3D::set_hframes(int p_amount) { ERR_FAIL_COND(p_amount < 1); hframes = p_amount; _queue_update(); - _change_notify("frame"); + _change_notify(); } int Sprite3D::get_hframes() const { diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index 5e6561adb7..cc81a4cb56 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "visibility_notifier.h" +#include "scene/3d/camera.h" #include "scene/3d/physics_body.h" #include "scene/animation/animation_player.h" #include "scene/scene_string_names.h" @@ -42,6 +43,7 @@ void VisibilityNotifier::_enter_camera(Camera *p_camera) { emit_signal(SceneStringNames::get_singleton()->screen_entered); _screen_enter(); } + emit_signal(SceneStringNames::get_singleton()->camera_entered, p_camera); } diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index 6f8c38eddd..1a294d016a 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -149,7 +149,7 @@ void VisualInstance::set_base(const RID &p_base) { VisualInstance::VisualInstance() { instance = VisualServer::get_singleton()->instance_create(); - VisualServer::get_singleton()->instance_attach_object_instance_ID(instance, get_instance_ID()); + VisualServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id()); layers = 1; set_notify_transform(true); } |