diff options
-rw-r--r-- | core/os/input.cpp | 2 | ||||
-rw-r--r-- | core/os/input.h | 2 | ||||
-rw-r--r-- | core/script_language.cpp | 3 | ||||
-rw-r--r-- | doc/classes/Input.xml | 4 | ||||
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 7 | ||||
-rw-r--r-- | drivers/gles2/shader_gles2.cpp | 14 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/texture_region_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/project_export.cpp | 76 | ||||
-rw-r--r-- | editor/project_export.h | 6 | ||||
-rw-r--r-- | main/input_default.cpp | 4 | ||||
-rw-r--r-- | main/input_default.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript.cpp | 7 | ||||
-rw-r--r-- | platform/x11/detect.py | 12 | ||||
-rw-r--r-- | scene/2d/cpu_particles_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 4 | ||||
-rw-r--r-- | scene/3d/cpu_particles.cpp | 2 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_sw.cpp | 4 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 31 |
19 files changed, 154 insertions, 34 deletions
diff --git a/core/os/input.cpp b/core/os/input.cpp index 4cd1f0b24a..1a24258a10 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -86,7 +86,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode); ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode); ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position); - ClassDB::bind_method(D_METHOD("action_press", "action"), &Input::action_press); + ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press); ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release); ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW)); ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2())); diff --git a/core/os/input.h b/core/os/input.h index db523d6789..dc2c213db2 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -113,7 +113,7 @@ public: virtual Vector3 get_magnetometer() const = 0; virtual Vector3 get_gyroscope() const = 0; - virtual void action_press(const StringName &p_action) = 0; + virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0; virtual void action_release(const StringName &p_action) = 0; void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; diff --git a/core/script_language.cpp b/core/script_language.cpp index 5b65da9ef1..496521486e 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -563,7 +563,8 @@ Variant PlaceHolderScriptInstance::property_get_fallback(const StringName &p_nam PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner) : owner(p_owner), language(p_language), - script(p_script) { + script(p_script), + build_failed(false) { } PlaceHolderScriptInstance::~PlaceHolderScriptInstance() { diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml index 38804e40b4..25a2f45773 100644 --- a/doc/classes/Input.xml +++ b/doc/classes/Input.xml @@ -17,8 +17,10 @@ </return> <argument index="0" name="action" type="String"> </argument> + <argument index="1" name="strength" type="float" default="1.0f"> + </argument> <description> - This will simulate pressing the specified action. + This will simulate pressing the specified action. The strength can be used for non-boolean actions. </description> </method> <method name="action_release"> diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 082c520480..723c44f2f6 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -80,11 +80,8 @@ static String _opstr(SL::Operator p_op) { static String _mkid(const String &p_id) { - StringBuffer<> id; - id += "m_"; - id += p_id; - - return id.as_string(); + String id = "m_" + p_id; + return id.replace("__", "_dus_"); //doubleunderscore is reserverd in glsl } static String f2sp0(float p_float) { diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp index 628a57c06d..c5a67d4e75 100644 --- a/drivers/gles2/shader_gles2.cpp +++ b/drivers/gles2/shader_gles2.cpp @@ -196,6 +196,12 @@ static void _display_error_with_code(const String &p_error, const Vector<const c ERR_PRINTS(p_error); } +static String _mkid(const String &p_id) { + + String id = "m_" + p_id; + return id.replace("__", "_dus_"); //doubleunderscore is reserverd in glsl +} + ShaderGLES2::Version *ShaderGLES2::get_current_version() { Version *_v = version_map.getptr(conditional_version); @@ -492,15 +498,15 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { if (cc) { // uniforms for (int i = 0; i < cc->custom_uniforms.size(); i++) { - StringName native_uniform_name = "m_" + cc->custom_uniforms[i]; - GLint location = glGetUniformLocation(v.id, ((String)native_uniform_name).ascii().get_data()); + String native_uniform_name = _mkid(cc->custom_uniforms[i]); + GLint location = glGetUniformLocation(v.id, (native_uniform_name).ascii().get_data()); v.custom_uniform_locations[cc->custom_uniforms[i]] = location; } // textures for (int i = 0; i < cc->texture_uniforms.size(); i++) { - StringName native_uniform_name = "m_" + cc->texture_uniforms[i]; - GLint location = glGetUniformLocation(v.id, ((String)native_uniform_name).ascii().get_data()); + String native_uniform_name = _mkid(cc->texture_uniforms[i]); + GLint location = glGetUniformLocation(v.id, (native_uniform_name).ascii().get_data()); v.custom_uniform_locations[cc->texture_uniforms[i]] = location; } } diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index be36b41417..03619b941c 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -167,7 +167,8 @@ static String _opstr(SL::Operator p_op) { static String _mkid(const String &p_id) { - return "m_" + p_id; + String id = "m_" + p_id; + return id.replace("__", "_dus_"); //doubleunderscore is reserverd in glsl } static String f2sp0(float p_float) { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 33e1f7c6a3..7c3e524d89 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -846,7 +846,8 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) { p->set_item_checked(0, true); p->connect("id_pressed", this, "_set_snap_mode"); hb_grid = memnew(HBoxContainer); - hb_tools->add_child(hb_grid); + //hb_tools->add_child(hb_grid); + main_vb->add_child(hb_grid); hb_grid->add_child(memnew(VSeparator)); hb_grid->add_child(memnew(Label(TTR("Offset:")))); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index f4f1f8068d..27d8bd97fb 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -165,6 +165,27 @@ void ProjectExportDialog::_update_presets() { updating = false; } +void ProjectExportDialog::_update_export_all() { + + bool can_export = EditorExport::get_singleton()->get_export_preset_count() > 0 ? true : false; + + for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { + Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i); + bool needs_templates; + String error; + if (preset->get_export_path() == "" || !preset->get_platform()->can_export(preset, error, needs_templates)) { + can_export = false; + break; + } + } + + if (can_export) { + export_all_button->set_disabled(false); + } else { + export_all_button->set_disabled(true); + } +} + void ProjectExportDialog::_edit_preset(int p_index) { if (p_index < 0 || p_index >= presets->get_item_count()) { @@ -267,6 +288,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { custom_features->set_text(current->get_custom_features()); _update_feature_list(); + _update_export_all(); updating = false; } @@ -864,6 +886,42 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) { } } +void ProjectExportDialog::_export_all_dialog() { + + export_all_dialog->show(); + export_all_dialog->popup_centered_minsize(Size2(300, 80)); +} + +void ProjectExportDialog::_export_all_dialog_action(const String &p_str) { + + export_all_dialog->hide(); + + _export_all(p_str == "release" ? false : true); +} + +void ProjectExportDialog::_export_all(bool p_debug) { + + String mode = p_debug ? TTR("Debug") : TTR("Release"); + EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count()); + + for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { + Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i); + ERR_FAIL_COND(preset.is_null()); + Ref<EditorExportPlatform> platform = preset->get_platform(); + ERR_FAIL_COND(platform.is_null()); + + ep.step(preset->get_name(), i); + + Error err = platform->export_project(preset, p_debug, preset->get_export_path(), 0); + if (err != OK) { + error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " " + platform->get_name()); + error_dialog->show(); + error_dialog->popup_centered_minsize(Size2(300, 80)); + ERR_PRINT("Failed to export project"); + } + } +} + void ProjectExportDialog::_bind_methods() { ClassDB::bind_method("_add_preset", &ProjectExportDialog::_add_preset); @@ -890,6 +948,9 @@ void ProjectExportDialog::_bind_methods() { ClassDB::bind_method("_validate_export_path", &ProjectExportDialog::_validate_export_path); ClassDB::bind_method("_export_project", &ProjectExportDialog::_export_project); ClassDB::bind_method("_export_project_to_path", &ProjectExportDialog::_export_project_to_path); + ClassDB::bind_method("_export_all", &ProjectExportDialog::_export_all); + ClassDB::bind_method("_export_all_dialog", &ProjectExportDialog::_export_all_dialog); + ClassDB::bind_method("_export_all_dialog_action", &ProjectExportDialog::_export_all_dialog_action); ClassDB::bind_method("_custom_features_changed", &ProjectExportDialog::_custom_features_changed); ClassDB::bind_method("_tab_changed", &ProjectExportDialog::_tab_changed); } @@ -1059,6 +1120,19 @@ ProjectExportDialog::ProjectExportDialog() { // Disable initially before we select a valid preset export_button->set_disabled(true); + export_all_dialog = memnew(ConfirmationDialog); + add_child(export_all_dialog); + export_all_dialog->set_title("Export All"); + export_all_dialog->set_text(TTR("Export mode?")); + export_all_dialog->get_ok()->hide(); + export_all_dialog->add_button(TTR("Debug"), true, "debug"); + export_all_dialog->add_button(TTR("Release"), true, "release"); + export_all_dialog->connect("custom_action", this, "_export_all_dialog_action"); + + export_all_button = add_button(TTR("Export All"), !OS::get_singleton()->get_swap_ok_cancel(), "export"); + export_all_button->connect("pressed", this, "_export_all_dialog"); + export_all_button->set_disabled(true); + export_pck_zip = memnew(FileDialog); export_pck_zip->add_filter("*.zip ; ZIP File"); export_pck_zip->add_filter("*.pck ; Godot Game Pack"); @@ -1122,6 +1196,8 @@ ProjectExportDialog::ProjectExportDialog() { default_filename = "UnnamedProject"; } } + + _update_export_all(); } ProjectExportDialog::~ProjectExportDialog() { diff --git a/editor/project_export.h b/editor/project_export.h index 23a6db8942..7009968138 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -93,6 +93,8 @@ private: ConfirmationDialog *patch_erase; Button *export_button; + Button *export_all_button; + AcceptDialog *export_all_dialog; LineEdit *custom_features; RichTextLabel *custom_feature_display; @@ -114,6 +116,7 @@ private: void _duplicate_preset(); void _delete_preset(); void _delete_preset_confirm(); + void _update_export_all(); void _update_presets(); @@ -143,6 +146,9 @@ private: void _validate_export_path(const String &p_path); void _export_project(); void _export_project_to_path(const String &p_path); + void _export_all_dialog(); + void _export_all_dialog_action(const String &p_str); + void _export_all(bool p_debug); void _update_feature_list(); void _custom_features_changed(const String &p_text); diff --git a/main/input_default.cpp b/main/input_default.cpp index e8015400af..b1084900d6 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -556,14 +556,14 @@ Point2i InputDefault::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_moti void InputDefault::iteration(float p_step) { } -void InputDefault::action_press(const StringName &p_action) { +void InputDefault::action_press(const StringName &p_action, float p_strength) { Action action; action.physics_frame = Engine::get_singleton()->get_physics_frames(); action.idle_frame = Engine::get_singleton()->get_idle_frames(); action.pressed = true; - action.strength = 0.f; + action.strength = p_strength; action_state[p_action] = action; } diff --git a/main/input_default.h b/main/input_default.h index 4964b9a83c..b6767669f0 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -227,7 +227,7 @@ public: void set_main_loop(MainLoop *p_main_loop); void set_mouse_position(const Point2 &p_posf); - void action_press(const StringName &p_action); + void action_press(const StringName &p_action, float p_strength = 1.f); void action_release(const StringName &p_action); void iteration(float p_step); diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index ef86ccae14..159085df34 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -469,8 +469,15 @@ bool GDScript::_update_exports() { for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { E->get()->set_build_failed(true); } + return false; } } else { + if (!valid) { + for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { + E->get()->set_build_failed(true); + } + return false; + } } if (base_cache.is_valid()) { diff --git a/platform/x11/detect.py b/platform/x11/detect.py index ee59e9b5a1..dc5c22b4b3 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -149,6 +149,18 @@ def configure(env): env.Append(CCFLAGS=['-pipe']) env.Append(LINKFLAGS=['-pipe']) + # Check for gcc version > 4 before adding -no-pie + import re + import subprocess + proc = subprocess.Popen([env['CXX'], '--version'], stdout=subprocess.PIPE) + (stdout, _) = proc.communicate() + match = re.search('[0-9][0-9.]*', stdout) + if match is not None: + version = match.group().split('.') + if (version[0] > '4'): + env.Append(CCFLAGS=['-fpie']) + env.Append(LINKFLAGS=['-no-pie']) + ## Dependencies env.ParseConfig('pkg-config x11 --cflags --libs') diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index b6e2f4f5cd..bc2bd9a1c5 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -1265,7 +1265,7 @@ void CPUParticles2D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_INITIAL_LINEAR_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_INITIAL_LINEAR_VELOCITY); ADD_GROUP("Angular Velocity", "angular_"); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-360,360,0.01"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-720,720,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGULAR_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angular_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGULAR_VELOCITY); /* diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index a7ac2bb982..8fe65f53a9 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1114,6 +1114,8 @@ void TileMap::_set_tile_data(const PoolVector<int> &p_data) { */ set_cell(x, y, v, flip_h, flip_v, transpose, Vector2(coord_x, coord_y)); } + + format = FORMAT_2; } PoolVector<int> TileMap::_get_tile_data() const { @@ -1403,7 +1405,7 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) { bool TileMap::_get(const StringName &p_name, Variant &r_ret) const { if (p_name == "format") { - r_ret = FORMAT_2; + r_ret = format; return true; } else if (p_name == "tile_data") { r_ret = _get_tile_data(); diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index e17e65c97e..5b3229e931 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -1302,7 +1302,7 @@ void CPUParticles::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param", "get_param", PARAM_INITIAL_LINEAR_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "initial_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_INITIAL_LINEAR_VELOCITY); ADD_GROUP("Angular Velocity", "angular_"); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-360,360,0.01"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity", PROPERTY_HINT_RANGE, "-720,720,0.01,or_lesser,or_greater"), "set_param", "get_param", PARAM_ANGULAR_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_velocity_random", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param_randomness", "get_param_randomness", PARAM_ANGULAR_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angular_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_param_curve", "get_param_curve", PARAM_ANGULAR_VELOCITY); /* diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 80588c05e6..2df09057c4 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -169,7 +169,9 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 & cbk->invalid_by_dir++; return; } - if (cbk->valid_dir.dot((p_point_A - p_point_B).normalized()) < 0.7071) { //sqrt(2)/2.0 + Vector2 rel_dir = (p_point_A - p_point_B).normalized(); + + if (cbk->valid_dir.dot(rel_dir) < 0.7071) { //sqrt(2)/2.0 - 45 degrees cbk->invalid_by_dir++; /* diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 0e83993472..23c3c739c2 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -579,9 +579,11 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t } } + Transform2D col_obj_shape_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); + if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) { - cbk.valid_dir = body_shape_xform.get_axis(1).normalized(); + cbk.valid_dir = col_obj_shape_xform.get_axis(1).normalized(); cbk.valid_depth = p_margin; //only valid depth is the collision margin cbk.invalid_by_dir = 0; @@ -592,7 +594,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t } 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)) { + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), cbkres, cbkptr, NULL, p_margin)) { if (cbk.amount > 0) { collided = true; } @@ -745,9 +747,12 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co } } + Transform2D col_obj_shape_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); + if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) { - cbk.valid_dir = body_shape_xform.get_axis(1).normalized(); + cbk.valid_dir = col_obj_shape_xform.get_axis(1).normalized(); + cbk.valid_depth = p_margin; //only valid depth is the collision margin cbk.invalid_by_dir = 0; @@ -773,7 +778,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co bool did_collide = false; 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)) { + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), cbkres, cbkptr, NULL, p_margin)) { did_collide = cbk.amount > current_collisions; } @@ -878,14 +883,14 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co continue; } - Transform2D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(col_shape_idx); + Transform2D col_obj_shape_xform = col_obj->get_transform() * col_obj->get_shape_transform(col_shape_idx); //test initial overlap, does it collide if going all the way? - if (!CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion, against_shape, col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { + if (!CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion, against_shape, col_obj_shape_xform, Vector2(), NULL, NULL, NULL, 0)) { continue; } //test initial overlap - if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), NULL, NULL, NULL, 0)) { if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) { continue; @@ -905,7 +910,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, against_shape, col_obj_xform, Vector2(), NULL, NULL, &sep, 0); + bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * ofs, against_shape, col_obj_shape_xform, Vector2(), NULL, NULL, &sep, 0); if (collided) { @@ -923,12 +928,12 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.max = 1; cbk.amount = 0; cbk.ptr = cd; - cbk.valid_dir = body_shape_xform.get_axis(1).normalized(); + cbk.valid_dir = col_obj_shape_xform.get_axis(1).normalized(); cbk.valid_depth = 10e20; Vector2 sep = mnormal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(col_shape_idx), col_obj_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0); + bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(col_shape_idx), col_obj_shape_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0); if (!collided || cbk.amount == 0) { continue; } @@ -1013,9 +1018,11 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (excluded) continue; + Transform2D col_obj_shape_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); + if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) { - rcd.valid_dir = body_shape_xform.get_axis(1).normalized(); + rcd.valid_dir = col_obj_shape_xform.get_axis(1).normalized(); rcd.valid_depth = 10e20; } else { rcd.valid_dir = Vector2(); @@ -1024,7 +1031,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(), against_shape, 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_shape_xform, Vector2(), _rest_cbk_result, &rcd, NULL, p_margin); if (!sc) continue; } |