From 1ba349b563afed07100de36b84b29e28e5beaaa8 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Fri, 5 Aug 2022 14:11:18 -0400 Subject: [PATCH] [custom levels] add collide mode option (#1730) add collide mode option --- custom_levels/blender/opengoal.py | 12 +++++++++++- goalc/build_level/collide_common.h | 2 +- goalc/build_level/gltf_mesh_extract.cpp | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/custom_levels/blender/opengoal.py b/custom_levels/blender/opengoal.py index cb95ba287c..e875ad36ee 100644 --- a/custom_levels/blender/opengoal.py +++ b/custom_levels/blender/opengoal.py @@ -1,7 +1,7 @@ bl_info = { "name": "OpenGOAL Mesh", "author": "water111", - "version": (0, 0, 2), + "version": (0, 0, 3), "blender": (2, 83, 0), "location": "3D View", "description": "OpenGOAL Mesh tools", @@ -65,6 +65,12 @@ pat_events = [ ("melt", "melt", "", 6), ] +pat_modes = [ + ("ground", "ground", "", 0), + ("wall", "wall", "", 1), + ("obstacle", "obstacle", "", 2), +] + def draw_func(self, context): layout = self.layout ob = context.object @@ -72,6 +78,7 @@ def draw_func(self, context): layout.prop(ob.active_material, "set_collision") if (ob.active_material.set_collision): layout.prop(ob.active_material, "ignore") + layout.prop(ob.active_material, "collide_mode") layout.prop(ob.active_material, "collide_material") layout.prop(ob.active_material, "collide_event") layout.prop(ob.active_material, "noedge") @@ -86,6 +93,7 @@ def draw_func_ob(self, context): layout.prop(ob, "set_collision") if (ob.set_collision): layout.prop(ob, "ignore") + layout.prop(ob, "collide_mode") layout.prop(ob, "collide_material") layout.prop(ob, "collide_event") layout.prop(ob, "noedge") @@ -103,6 +111,7 @@ def register(): bpy.types.Material.nocamera = bpy.props.BoolProperty(name="No-Camera") bpy.types.Material.collide_material = bpy.props.EnumProperty(items = pat_surfaces, name = "Material") bpy.types.Material.collide_event = bpy.props.EnumProperty(items = pat_events, name = "Event") + bpy.types.Material.collide_mode = bpy.props.EnumProperty(items = pat_modes, name = "Mode") bpy.types.MATERIAL_PT_custom_props.prepend(draw_func) bpy.types.Object.set_invisible = bpy.props.BoolProperty(name="Invisible") @@ -114,6 +123,7 @@ def register(): bpy.types.Object.nocamera = bpy.props.BoolProperty(name="No-Camera") bpy.types.Object.collide_material = bpy.props.EnumProperty(items = pat_surfaces, name = "Material") bpy.types.Object.collide_event = bpy.props.EnumProperty(items = pat_events, name = "Event") + bpy.types.Object.collide_mode = bpy.props.EnumProperty(items = pat_modes, name = "Mode") bpy.types.OBJECT_PT_custom_props.prepend(draw_func_ob) def unregister(): diff --git a/goalc/build_level/collide_common.h b/goalc/build_level/collide_common.h index a904d02974..a2da824600 100644 --- a/goalc/build_level/collide_common.h +++ b/goalc/build_level/collide_common.h @@ -3,7 +3,7 @@ #include "common/math/Vector.h" struct PatSurface { - enum class Mode { GROUND = 0, WALL = 1, OBSTACLE = 2 }; + enum class Mode { GROUND = 0, WALL = 1, OBSTACLE = 2, MAX_MODE = 3 }; enum class Material { STONE = 0, ICE = 1, diff --git a/goalc/build_level/gltf_mesh_extract.cpp b/goalc/build_level/gltf_mesh_extract.cpp index 6e7767d3be..ccad587db3 100644 --- a/goalc/build_level/gltf_mesh_extract.cpp +++ b/goalc/build_level/gltf_mesh_extract.cpp @@ -711,6 +711,12 @@ PatResult custom_props_to_pat(const tinygltf::Value& val, const std::string& /*d result.pat.set_noedge(true); } + if (val.Has("collide_mode")) { + int mode = val.Get("collide_mode").Get(); + ASSERT(mode < (int)PatSurface::Mode::MAX_MODE); + result.pat.set_mode(PatSurface::Mode(mode)); + } + if (val.Get("nocamera").Get()) { result.pat.set_nocamera(true); }