summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2015-01-05 23:56:24 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2015-01-05 23:56:24 +0300
commita7875c586af74302584544d777b189f4cb85c393 (patch)
treef4929f77383d835b5be8b6e099b9db59000af610 /scene/3d
parent4ab1bcde35a02cfe7b25d630720de1cc81ef5a1a (diff)
parent8c4dd8de3919b789eac1a0f030563008bdcd44f5 (diff)
Merge branch 'master' of github.com:okamstudio/godot
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/camera.cpp35
-rw-r--r--scene/3d/camera.h8
-rw-r--r--scene/3d/collision_object.cpp5
-rw-r--r--scene/3d/immediate_geometry.cpp2
-rw-r--r--scene/3d/physics_body.cpp5
-rw-r--r--scene/3d/ray_cast.cpp58
-rw-r--r--scene/3d/ray_cast.h9
-rw-r--r--scene/3d/spatial_sample_player.cpp1
-rw-r--r--scene/3d/sprite_3d.cpp2
9 files changed, 104 insertions, 21 deletions
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 1db9886261..27420f8002 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -86,6 +86,10 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
set_keep_aspect_mode(KeepAspect(int(p_value)));
else if (p_name=="vaspect")
set_keep_aspect_mode(p_value?KEEP_WIDTH:KEEP_HEIGHT);
+ else if (p_name=="h_offset")
+ h_offset=p_value;
+ else if (p_name=="v_offset")
+ v_offset=p_value;
else if (p_name=="current") {
if (p_value.operator bool()) {
make_current();
@@ -128,6 +132,10 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const {
}
} else if (p_name=="visible_layers") {
r_ret=get_visible_layers();
+ } else if (p_name=="h_offset") {
+ r_ret=get_h_offset();
+ } else if (p_name=="v_offset") {
+ r_ret=get_v_offset();
} else if (p_name=="environment") {
r_ret=get_environment();
} else
@@ -170,12 +178,16 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) );
p_list->push_back( PropertyInfo( Variant::INT, "visible_layers",PROPERTY_HINT_ALL_FLAGS ) );
p_list->push_back( PropertyInfo( Variant::OBJECT, "environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment" ) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "h_offset" ) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "v_offset" ) );
}
void Camera::_update_camera() {
Transform tr = get_camera_transform();
+ tr.origin+=tr.basis.get_axis(1)*v_offset;
+ tr.origin+=tr.basis.get_axis(0)*h_offset;
VisualServer::get_singleton()->camera_set_transform( camera, tr );
// here goes listener stuff
@@ -757,6 +769,27 @@ void Camera::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, cons
}
+void Camera::set_v_offset(float p_offset) {
+
+ v_offset=p_offset;
+ _update_camera();;
+}
+
+float Camera::get_v_offset() const {
+
+ return v_offset;
+}
+
+void Camera::set_h_offset(float p_offset) {
+ h_offset=p_offset;
+ _update_camera();
+}
+
+float Camera::get_h_offset() const {
+
+ return h_offset;
+}
+
Camera::Camera() {
@@ -772,6 +805,8 @@ Camera::Camera() {
set_perspective(60.0,0.1,100.0);
keep_aspect=KEEP_HEIGHT;
layers=0xfffff;
+ v_offset=0;
+ h_offset=0;
VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
//active=false;
}
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index bac8173bb7..950688dfda 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -61,6 +61,8 @@ private:
float fov;
float size;
float near,far;
+ float v_offset;
+ float h_offset;
KeepAspect keep_aspect;
RID camera;
@@ -140,6 +142,12 @@ public:
void look_at(const Vector3& p_target, const Vector3& p_up_normal);
void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
+ void set_v_offset(float p_offset);
+ float get_v_offset() const;
+
+ void set_h_offset(float p_offset);
+ float get_h_offset() const;
+
Camera();
~Camera();
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 82158405ea..9c388a2883 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -47,6 +47,11 @@ void CollisionObject::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
+ if (area)
+ PhysicsServer::get_singleton()->area_set_transform(rid,get_global_transform());
+ else
+ PhysicsServer::get_singleton()->body_set_state(rid,PhysicsServer::BODY_STATE_TRANSFORM,get_global_transform());
+
RID space = get_world()->get_space();
if (area) {
PhysicsServer::get_singleton()->area_set_space(rid,space);
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index a4206894ff..651d20ae71 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -127,7 +127,7 @@ void ImmediateGeometry::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_color","color"),&ImmediateGeometry::set_color);
ObjectTypeDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv);
ObjectTypeDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
- ObjectTypeDB::bind_method(_MD("add_vertex","color"),&ImmediateGeometry::add_vertex);
+ ObjectTypeDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius"),&ImmediateGeometry::add_sphere);
ObjectTypeDB::bind_method(_MD("end"),&ImmediateGeometry::end);
ObjectTypeDB::bind_method(_MD("clear"),&ImmediateGeometry::clear);
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 5c047b3fef..f2806f2af2 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -852,6 +852,8 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
//motion recover
for(int i=0;i<get_shape_count();i++) {
+ if (is_shape_set_as_trigger(i))
+ continue;
if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),m,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask)) {
collided=true;
@@ -870,9 +872,6 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
for(int j=0;j<8;j++) {
for(int i=0;i<res_shapes;i++) {
- if (is_shape_set_as_trigger(i))
- continue;
-
Vector3 a = sr[i*2+0];
Vector3 b = sr[i*2+1];
//print_line(String()+a+" -> "+b);
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 6bc0c677c0..639a86e759 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -95,18 +95,6 @@ void RayCast::_notification(int p_what) {
if (enabled && !get_tree()->is_editor_hint()) {
set_fixed_process(true);
- Node *p = get_parent();
- while( p && p->cast_to<Spatial>() ) {
-
- CollisionObject *co = p->cast_to<CollisionObject>();
- if (co) {
-
- exception=co->get_rid();
- exceptions.insert(exception);
- }
-
- p=p->get_parent();
- }
} else
set_fixed_process(false);
@@ -119,7 +107,6 @@ void RayCast::_notification(int p_what) {
set_fixed_process(false);
}
- exceptions.erase(exception);
} break;
case NOTIFICATION_FIXED_PROCESS: {
@@ -143,7 +130,7 @@ void RayCast::_notification(int p_what) {
PhysicsDirectSpaceState::RayResult rr;
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exceptions)) {
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude)) {
collided=true;
against=rr.collider_id;
@@ -160,6 +147,41 @@ void RayCast::_notification(int p_what) {
}
}
+void RayCast::add_exception_rid(const RID& p_rid) {
+
+ exclude.insert(p_rid);
+}
+
+void RayCast::add_exception(const Object* p_object){
+
+ ERR_FAIL_NULL(p_object);
+ CollisionObject *co=((Object*)p_object)->cast_to<CollisionObject>();
+ if (!co)
+ return;
+ add_exception_rid(co->get_rid());
+}
+
+void RayCast::remove_exception_rid(const RID& p_rid) {
+
+ exclude.erase(p_rid);
+}
+
+void RayCast::remove_exception(const Object* p_object){
+
+ ERR_FAIL_NULL(p_object);
+ CollisionObject *co=((Object*)p_object)->cast_to<CollisionObject>();
+ if (!co)
+ return;
+ remove_exception_rid(co->get_rid());
+}
+
+
+void RayCast::clear_exceptions(){
+
+ exclude.clear();
+}
+
+
void RayCast::_bind_methods() {
@@ -176,6 +198,14 @@ void RayCast::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_collision_point"),&RayCast::get_collision_point);
ObjectTypeDB::bind_method(_MD("get_collision_normal"),&RayCast::get_collision_normal);
+ ObjectTypeDB::bind_method(_MD("add_exception_rid","rid"),&RayCast::add_exception_rid);
+ ObjectTypeDB::bind_method(_MD("add_exception","node"),&RayCast::add_exception);
+
+ ObjectTypeDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast::remove_exception_rid);
+ ObjectTypeDB::bind_method(_MD("remove_exception","node"),&RayCast::remove_exception);
+
+ ObjectTypeDB::bind_method(_MD("clear_exceptions"),&RayCast::clear_exceptions);
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
}
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index 96606b1628..0239c61b67 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -45,8 +45,7 @@ class RayCast : public Spatial {
Vector3 cast_to;
- RID exception;
- Set<RID> exceptions;
+ Set<RID> exclude;
protected:
@@ -66,6 +65,12 @@ public:
Vector3 get_collision_point() const;
Vector3 get_collision_normal() const;
+ void add_exception_rid(const RID& p_rid);
+ void add_exception(const Object* p_object);
+ void remove_exception_rid(const RID& p_rid);
+ void remove_exception(const Object* p_object);
+ void clear_exceptions();
+
RayCast();
};
diff --git a/scene/3d/spatial_sample_player.cpp b/scene/3d/spatial_sample_player.cpp
index b4a5d3bc1b..6dc71e06ad 100644
--- a/scene/3d/spatial_sample_player.cpp
+++ b/scene/3d/spatial_sample_player.cpp
@@ -103,6 +103,7 @@ void SpatialSamplePlayer::_notification(int p_what) {
void SpatialSamplePlayer::set_sample_library(const Ref<SampleLibrary>& p_library) {
library=p_library;
+ _change_notify();
}
Ref<SampleLibrary> SpatialSamplePlayer::get_sample_library() const {
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 77f2cf5cc1..35f6523c6a 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -497,7 +497,7 @@ void Sprite3D::set_frame(int p_frame) {
frame=p_frame;
_queue_update();
- ADD_SIGNAL(MethodInfo("frame_changed"));
+ emit_signal(SceneStringNames::get_singleton()->frame_changed);
}