[custom levels] add collide mode option (#1730)

add collide mode option
This commit is contained in:
water111
2022-08-05 14:11:18 -04:00
committed by GitHub
parent e52a88656f
commit 1ba349b563
3 changed files with 18 additions and 2 deletions
+11 -1
View File
@@ -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():
+1 -1
View File
@@ -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,
+6
View File
@@ -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<int>();
ASSERT(mode < (int)PatSurface::Mode::MAX_MODE);
result.pat.set_mode(PatSurface::Mode(mode));
}
if (val.Get("nocamera").Get<int>()) {
result.pat.set_nocamera(true);
}