diff options
Diffstat (limited to 'servers')
| -rw-r--r-- | servers/physics_2d/physics_2d_server_sw.cpp | 3 | ||||
| -rw-r--r-- | servers/physics_2d/physics_2d_server_sw.h | 1 | ||||
| -rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 60 | ||||
| -rw-r--r-- | servers/physics_server.cpp | 2 | ||||
| -rw-r--r-- | servers/visual/rasterizer.h | 1 | ||||
| -rw-r--r-- | servers/visual/shader_language.cpp | 8 | ||||
| -rw-r--r-- | servers/visual/shader_types.cpp | 3 | ||||
| -rw-r--r-- | servers/visual/visual_server_raster.h | 1 | ||||
| -rw-r--r-- | servers/visual/visual_server_scene.cpp | 2 | ||||
| -rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 1 | ||||
| -rw-r--r-- | servers/visual_server.cpp | 1 | ||||
| -rw-r--r-- | servers/visual_server.h | 8 |
12 files changed, 74 insertions, 17 deletions
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 006c5fd7b5..e9e7122af3 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -130,9 +130,12 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 & if (cbk->valid_dir != Vector2()) { if (p_point_A.distance_squared_to(p_point_B) > cbk->valid_depth * cbk->valid_depth) { + cbk->invalid_by_dir++; return; } if (cbk->valid_dir.dot((p_point_A - p_point_B).normalized()) < 0.7071) { + cbk->invalid_by_dir++; + ; /* print_line("A: "+p_point_A); print_line("B: "+p_point_B); print_line("discard too angled "+rtos(cbk->valid_dir.dot((p_point_A-p_point_B)))); diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index 7d3c589fa9..dd310d7a93 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -74,6 +74,7 @@ public: real_t valid_depth; int max; int amount; + int invalid_by_dir; Vector2 *ptr; }; diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 9b2e586993..779f0d54ac 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -30,8 +30,8 @@ #include "space_2d_sw.h" #include "collision_solver_2d_sw.h" +#include "pair.h" #include "physics_2d_server_sw.h" - _FORCE_INLINE_ static bool _match_object_type_query(CollisionObject2DSW *p_object, uint32_t p_collision_layer, uint32_t p_type_mask) { if ((p_object->get_collision_layer() & p_collision_layer) == 0) @@ -517,6 +517,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co body_aabb = p_from.xform(p_body->get_inv_transform().xform(body_aabb)); body_aabb = body_aabb.grow(p_margin); + static const int max_excluded_shape_pairs = 32; + Pair<Shape2DSW *, Shape2DSW *> excluded_shape_pairs[max_excluded_shape_pairs]; + int excluded_shape_pair_count = 0; + Transform2D body_transform = p_from; { @@ -532,6 +536,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.max = max_results; cbk.amount = 0; cbk.ptr = sr; + cbk.invalid_by_dir = 0; + excluded_shape_pair_count = 0; //last step is the one valid Physics2DServerSW::CollCbkData *cbkptr = &cbk; CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk; @@ -555,14 +561,25 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.valid_dir = body_shape_xform.get_axis(1).normalized(); cbk.valid_depth = p_margin; //only valid depth is the collision margin + cbk.invalid_by_dir = 0; + } else { cbk.valid_dir = Vector2(); cbk.valid_depth = 0; + cbk.invalid_by_dir = 0; } - if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), cbkres, cbkptr, NULL, p_margin)) { + Shape2DSW *against_shape = col_obj->get_shape(shape_idx); + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), cbkres, cbkptr, NULL, p_margin)) { collided = cbk.amount > 0; } + + if (!collided && cbk.invalid_by_dir > 0) { + //this shape must be excluded + if (excluded_shape_pair_count < max_excluded_shape_pairs) { + excluded_shape_pairs[excluded_shape_pair_count++] = Pair<Shape2DSW *, Shape2DSW *>(body_shape, against_shape); + } + } } } @@ -622,15 +639,31 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co const CollisionObject2DSW *col_obj = intersection_query_results[i]; int shape_idx = intersection_query_subindex_results[i]; + Shape2DSW *against_shape = col_obj->get_shape(shape_idx); + + bool excluded = false; + + for (int k = 0; k < excluded_shape_pair_count; k++) { + + if (excluded_shape_pairs[k].first == body_shape && excluded_shape_pairs[k].second == against_shape) { + excluded = true; + break; + } + } + + if (excluded) { + + continue; + } Transform2D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); //test initial overlap, does it collide if going all the way? - if (!CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { + if (!CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion, against_shape, col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { continue; } //test initial overlap - if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { if (col_obj->is_shape_set_as_one_way_collision(j)) { continue; @@ -650,7 +683,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co real_t ofs = (low + hi) * 0.5; Vector2 sep = mnormal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * ofs, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), NULL, NULL, &sep, 0); + bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * ofs, against_shape, col_obj_xform, Vector2(), NULL, NULL, &sep, 0); if (collided) { @@ -669,7 +702,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.amount = 0; cbk.ptr = cd; cbk.valid_dir = body_shape_xform.get_axis(1).normalized(); - ; + cbk.valid_depth = 10e20; Vector2 sep = mnormal; //important optimization for this to work fast enough @@ -738,6 +771,19 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co const CollisionObject2DSW *col_obj = intersection_query_results[i]; int shape_idx = intersection_query_subindex_results[i]; + Shape2DSW *against_shape = col_obj->get_shape(shape_idx); + + bool excluded = false; + for (int k = 0; k < excluded_shape_pair_count; k++) { + + if (excluded_shape_pairs[k].first == body_shape && excluded_shape_pairs[k].second == against_shape) { + excluded = true; + break; + } + } + if (excluded) + continue; + if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) { rcd.valid_dir = body_shape_xform.get_axis(1).normalized(); @@ -749,7 +795,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co rcd.object = col_obj; rcd.shape = shape_idx; - bool sc = CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), _rest_cbk_result, &rcd, NULL, p_margin); + bool sc = CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), _rest_cbk_result, &rcd, NULL, p_margin); if (!sc) continue; } diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index 5097e0a5d2..d4e37be882 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -75,7 +75,7 @@ void PhysicsDirectBodyState::_bind_methods() { ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState::get_total_angular_damp); ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState::get_center_of_mass); - ClassDB::bind_method(D_METHOD("get_principal_inetria_axes"), &PhysicsDirectBodyState::get_principal_inertia_axes); + ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState::get_principal_inertia_axes); ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState::get_inverse_mass); ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState::get_inverse_inertia); diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 9e4acac25d..187a0b180b 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -213,6 +213,7 @@ public: virtual RID material_create() = 0; + virtual void material_set_render_priority(RID p_material, int priority) = 0; virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0; virtual RID material_get_shader(RID p_shader_material) const = 0; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index bc59acead5..09f8a3775e 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -1042,12 +1042,6 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type } } break; case OP_ASSIGN: { - - if (p_op->arguments[0]->type != Node::TYPE_MEMBER && p_op->arguments[0]->type != Node::TYPE_VARIABLE) { - valid = false; - break; - } - DataType na = p_op->arguments[0]->get_datatype(); DataType nb = p_op->arguments[1]->get_datatype(); valid = na == nb; @@ -3355,7 +3349,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct Token tk = _get_token(); if (tk.type != TK_SHADER_TYPE) { - _set_error("Expected 'shader_type' at the begining of shader."); + _set_error("Expected 'shader_type' at the beginning of shader."); return ERR_PARSE_ERROR; } diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index d8d1b1c1b1..ef0d063f83 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -128,12 +128,13 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_never"); shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_alpha_prepass"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_test_disable"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_front"); shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_back"); shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_disabled"); shader_modes[VS::SHADER_SPATIAL].modes.insert("unshaded"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("ontop"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_half_lambert"); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 774b692a22..3953bc5f48 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -690,6 +690,7 @@ public: BIND3(material_set_param, RID, const StringName &, const Variant &) BIND2RC(Variant, material_get_param, RID, const StringName &) + BIND2(material_set_render_priority, RID, int) BIND2(material_set_line_width, RID, float) BIND2(material_set_next_pass, RID, RID) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index cd68c14de8..2a6cba453c 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -1434,7 +1434,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam } ins->depth = near_plane.distance_to(ins->transform.origin); - ins->depth_layer = CLAMP(int(ins->depth * 8 / z_far), 0, 7); + ins->depth_layer = CLAMP(int(ins->depth * 16 / z_far), 0, 15); } if (!keep) { diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 7143178b04..f24049be92 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -128,6 +128,7 @@ public: FUNC3(material_set_param, RID, const StringName &, const Variant &) FUNC2RC(Variant, material_get_param, RID, const StringName &) + FUNC2(material_set_render_priority, RID, int) FUNC2(material_set_line_width, RID, float) FUNC2(material_set_next_pass, RID, RID) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 777feffb06..67b847d127 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1422,6 +1422,7 @@ Array VisualServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const { void VisualServer::_bind_methods() { + ClassDB::bind_method(D_METHOD("force_draw"), &VisualServer::draw); ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create); ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT)); //ClassDB::bind_method(D_METHOD("texture_allocate"),&VisualServer::texture_allocate,DEFVAL( TEXTURE_FLAGS_DEFAULT ) ); diff --git a/servers/visual_server.h b/servers/visual_server.h index 9f2d685531..45eaeeea25 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -166,6 +166,11 @@ public: /* COMMON MATERIAL API */ + enum { + MATERIAL_RENDER_PRIORITY_MIN = -128, + MATERIAL_RENDER_PRIORITY_MAX = 127, + + }; virtual RID material_create() = 0; virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0; @@ -174,6 +179,8 @@ public: virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0; virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0; + virtual void material_set_render_priority(RID p_material, int priority) = 0; + virtual void material_set_line_width(RID p_material, float p_width) = 0; virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0; @@ -358,6 +365,7 @@ public: LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET, LIGHT_PARAM_SHADOW_NORMAL_BIAS, LIGHT_PARAM_SHADOW_BIAS, + LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE, LIGHT_PARAM_MAX }; |