summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/arvr/arvr_script_interface.cpp136
-rw-r--r--servers/arvr/arvr_script_interface.h52
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h45
-rw-r--r--servers/register_server_types.cpp8
4 files changed, 36 insertions, 205 deletions
diff --git a/servers/arvr/arvr_script_interface.cpp b/servers/arvr/arvr_script_interface.cpp
deleted file mode 100644
index 2755605a14..0000000000
--- a/servers/arvr/arvr_script_interface.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-#include "arvr_script_interface.h"
-
-ARVRScriptInterface::ARVRScriptInterface() {
- // testing
- printf("Construct script interface");
-}
-
-ARVRScriptInterface::~ARVRScriptInterface() {
- if (is_initialized()) {
- uninitialize();
- };
-
- // testing
- printf("Destruct script interface");
-}
-
-StringName ARVRScriptInterface::get_name() const {
- if (get_script_instance() && get_script_instance()->has_method("get_name")) {
- return get_script_instance()->call("get_name");
- } else {
- // just return something for now
- return "ARVR Script interface";
- }
-}
-
-int ARVRScriptInterface::get_capabilities() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_capabilities")), ARVRInterface::ARVR_NONE);
- return get_script_instance()->call("get_capabilities");
-};
-
-ARVRInterface::Tracking_status ARVRScriptInterface::get_tracking_status() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_tracking_status")), ARVRInterface::ARVR_NOT_TRACKING);
- int status = get_script_instance()->call("get_tracking_status");
- return (ARVRInterface::Tracking_status)status;
-}
-
-bool ARVRScriptInterface::get_anchor_detection_is_enabled() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_anchor_detection_is_enabled")), false);
- return get_script_instance()->call("get_anchor_detection_is_enabled");
-};
-
-void ARVRScriptInterface::set_anchor_detection_is_enabled(bool p_enable) {
- ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("set_anchor_detection_is_enabled")));
- get_script_instance()->call("set_anchor_detection_is_enabled");
-};
-
-bool ARVRScriptInterface::is_stereo() {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_stereo")), false);
- return get_script_instance()->call("is_stereo");
-}
-
-bool ARVRScriptInterface::is_initialized() {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_initialized")), false);
- return get_script_instance()->call("is_initialized");
-}
-
-bool ARVRScriptInterface::initialize() {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("initialize")), false);
- return get_script_instance()->call("initialize");
-}
-
-void ARVRScriptInterface::uninitialize() {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- if (arvr_server != NULL) {
- // Whatever happens, make sure this is no longer our primary interface
- arvr_server->clear_primary_interface_if(this);
- }
-
- ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("uninitialize")));
- get_script_instance()->call("uninitialize");
-}
-
-Size2 ARVRScriptInterface::get_recommended_render_targetsize() {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_recommended_render_targetsize")), Size2());
- return get_script_instance()->call("get_recommended_render_targetsize");
-}
-
-Transform ARVRScriptInterface::get_transform_for_eye(Eyes p_eye, const Transform &p_cam_transform) {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_transform_for_eye")), Transform());
- return get_script_instance()->call("get_transform_for_eye", p_eye, p_cam_transform);
-}
-
-// Suggestion from Reduz, as we can't return a CameraMatrix, return a PoolVector with our 16 floats
-PoolVector<float> ARVRScriptInterface::_get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_projection_for_eye")), PoolVector<float>());
- return get_script_instance()->call("_get_projection_for_eye", p_eye, p_aspect, p_z_near, p_z_far);
-}
-
-CameraMatrix ARVRScriptInterface::get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
- CameraMatrix cm;
- int i = 0;
- int j = 0;
-
- PoolVector<float> cm_as_floats = _get_projection_for_eye(p_eye, p_aspect, p_z_near, p_z_far);
-
- for (int k = 0; k < cm_as_floats.size() && i < 4; k++) {
- cm.matrix[i][j] = cm_as_floats[k];
- j++;
- if (j == 4) {
- j = 0;
- i++;
- };
- };
-
- return cm;
-}
-
-void ARVRScriptInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
- ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("commit_for_eye")));
- get_script_instance()->call("commit_for_eye");
-}
-
-void ARVRScriptInterface::process() {
- ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("process")));
- get_script_instance()->call("process");
-}
-
-void ARVRScriptInterface::_bind_methods() {
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_capabilities"));
-
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_initialized"));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "initialize"));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo("uninitialize"));
-
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_tracking_status"));
-
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "get_anchor_detection_is_enabled"));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_anchor_detection_is_enabled", PropertyInfo(Variant::BOOL, "enabled")));
-
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_stereo"));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::VECTOR2, "get_recommended_render_targetsize"));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::TRANSFORM, "get_transform_for_eye", PropertyInfo(Variant::INT, "eye"), PropertyInfo(Variant::TRANSFORM, "cam_transform")));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo("_get_projection_for_eye"));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo("commit_for_eye", PropertyInfo(Variant::INT, "eye"), PropertyInfo(Variant::_RID, "render_target")));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo("process"));
-}
diff --git a/servers/arvr/arvr_script_interface.h b/servers/arvr/arvr_script_interface.h
deleted file mode 100644
index b1393b4fdb..0000000000
--- a/servers/arvr/arvr_script_interface.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef SCRIPT_INTERFACE_H
-#define SCRIPT_INTERFACE_H
-
-#include "arvr_interface.h"
-
-/**
- @authors Hinsbart & Karroffel
-
- This subclass of our AR/VR interface forms a bridge to GDNative.
-*/
-
-class ARVRScriptInterface : public ARVRInterface {
- GDCLASS(ARVRScriptInterface, ARVRInterface);
-
-protected:
- static void _bind_methods();
-
-public:
- /** general interface information **/
- ARVRScriptInterface();
- ~ARVRScriptInterface();
-
- virtual StringName get_name() const;
- virtual int get_capabilities() const;
-
- virtual bool is_initialized();
- virtual bool initialize();
- virtual void uninitialize();
-
- ARVRInterface::Tracking_status get_tracking_status() const; /* get the status of our current tracking */
-
- /** specific to AR **/
- virtual bool get_anchor_detection_is_enabled() const;
- virtual void set_anchor_detection_is_enabled(bool p_enable);
-
- /** rendering and internal **/
- virtual Size2 get_recommended_render_targetsize();
- virtual bool is_stereo();
- virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
-
- // we expose a PoolVector<float> version of this function to GDNative
- PoolVector<float> _get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
-
- // and a CameraMatrix version to ARVRServer
- virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
-
- virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
-
- virtual void process();
-};
-
-#endif // SCRIPT_INTERFACE_H
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index db1270633f..627ba8ea15 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -110,21 +110,48 @@ public:
void set_shape_metadata(int p_index, const Variant &p_metadata);
_FORCE_INLINE_ int get_shape_count() const { return shapes.size(); }
- _FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const { return shapes[p_index].shape; }
- _FORCE_INLINE_ const Transform2D &get_shape_transform(int p_index) const { return shapes[p_index].xform; }
- _FORCE_INLINE_ const Transform2D &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; }
- _FORCE_INLINE_ const Rect2 &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; }
- _FORCE_INLINE_ const Variant &get_shape_metadata(int p_index) const { return shapes[p_index].metadata; }
+ _FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, shapes.size(), NULL);
+ return shapes[p_index].shape;
+ }
+ _FORCE_INLINE_ const Transform2D &get_shape_transform(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, shapes.size(), Transform2D());
+ return shapes[p_index].xform;
+ }
+ _FORCE_INLINE_ const Transform2D &get_shape_inv_transform(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, shapes.size(), Transform2D());
+ return shapes[p_index].xform_inv;
+ }
+ _FORCE_INLINE_ const Rect2 &get_shape_aabb(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, shapes.size(), Rect2());
+ return shapes[p_index].aabb_cache;
+ }
+ _FORCE_INLINE_ const Variant &get_shape_metadata(int p_index) const {
+ ERR_FAIL_INDEX_V(p_index, shapes.size(), Variant());
+ return shapes[p_index].metadata;
+ }
_FORCE_INLINE_ Transform2D get_transform() const { return transform; }
_FORCE_INLINE_ Transform2D get_inv_transform() const { return inv_transform; }
_FORCE_INLINE_ Space2DSW *get_space() const { return space; }
- _FORCE_INLINE_ void set_shape_as_disabled(int p_idx, bool p_disabled) { shapes[p_idx].disabled = p_disabled; }
- _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const { return shapes[p_idx].disabled; }
+ _FORCE_INLINE_ void set_shape_as_disabled(int p_idx, bool p_disabled) {
+ ERR_FAIL_INDEX(p_idx, shapes.size());
+ shapes[p_idx].disabled = p_disabled;
+ }
+ _FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, shapes.size(), false);
+ return shapes[p_idx].disabled;
+ }
- _FORCE_INLINE_ void set_shape_as_one_way_collision(int p_idx, bool p_one_way_collision) { shapes[p_idx].one_way_collision = p_one_way_collision; }
- _FORCE_INLINE_ bool is_shape_set_as_one_way_collision(int p_idx) const { return shapes[p_idx].one_way_collision; }
+ _FORCE_INLINE_ void set_shape_as_one_way_collision(int p_idx, bool p_one_way_collision) {
+ ERR_FAIL_INDEX(p_idx, shapes.size());
+ shapes[p_idx].one_way_collision = p_one_way_collision;
+ }
+ _FORCE_INLINE_ bool is_shape_set_as_one_way_collision(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, shapes.size(), false);
+ return shapes[p_idx].one_way_collision;
+ }
void set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; }
_FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; }
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 1aee2144aa..7a9328e30f 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -32,7 +32,6 @@
#include "arvr/arvr_interface.h"
#include "arvr/arvr_positional_tracker.h"
-#include "arvr/arvr_script_interface.h"
#include "arvr_server.h"
#include "audio/audio_effect.h"
#include "audio/audio_stream.h"
@@ -74,10 +73,8 @@ static void _debugger_get_resource_usage(List<ScriptDebuggerRemote::ResourceUsag
}
ShaderTypes *shader_types = NULL;
-ARVRServer *arvr_server = NULL;
void register_server_types() {
- arvr_server = memnew(ARVRServer);
ClassDB::register_virtual_class<VisualServer>();
ClassDB::register_class<AudioServer>();
@@ -95,7 +92,6 @@ void register_server_types() {
ClassDB::register_virtual_class<ARVRInterface>();
ClassDB::register_class<ARVRPositionalTracker>();
- ClassDB::register_class<ARVRScriptInterface>();
ClassDB::register_virtual_class<AudioStream>();
ClassDB::register_virtual_class<AudioStreamPlayback>();
@@ -152,9 +148,5 @@ void register_server_types() {
void unregister_server_types() {
- //@TODO move this into iPhone/Android implementation? just have this here for testing...
- // mobile_interface = NULL;
-
memdelete(shader_types);
- memdelete(arvr_server);
}