From e52a88656f79c8e380a0b655a8d41805f3f402b2 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Fri, 5 Aug 2022 13:00:10 -0400 Subject: [PATCH] [custom levels] add invisible option (#1729) --- custom_levels/blender/opengoal.py | 14 +++++++++----- goalc/build_level/gltf_mesh_extract.cpp | 11 +++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/custom_levels/blender/opengoal.py b/custom_levels/blender/opengoal.py index dcffcaddfd..cb95ba287c 100644 --- a/custom_levels/blender/opengoal.py +++ b/custom_levels/blender/opengoal.py @@ -1,13 +1,13 @@ bl_info = { "name": "OpenGOAL Mesh", "author": "water111", - "version": (0, 0, 1), + "version": (0, 0, 2), "blender": (2, 83, 0), "location": "3D View", "description": "OpenGOAL Mesh tools", "category": "Development" } - + import bpy import colorsys import bmesh @@ -64,10 +64,11 @@ pat_events = [ ("burnup", "burnup", "", 5), ("melt", "melt", "", 6), ] - + def draw_func(self, context): layout = self.layout ob = context.object + layout.prop(ob.active_material, "set_invisible") layout.prop(ob.active_material, "set_collision") if (ob.active_material.set_collision): layout.prop(ob.active_material, "ignore") @@ -77,10 +78,11 @@ def draw_func(self, context): layout.prop(ob.active_material, "noentity") layout.prop(ob.active_material, "nolineofsight") layout.prop(ob.active_material, "nocamera") - + def draw_func_ob(self, context): layout = self.layout ob = context.object + layout.prop(ob, "set_invisible") layout.prop(ob, "set_collision") if (ob.set_collision): layout.prop(ob, "ignore") @@ -92,6 +94,7 @@ def draw_func_ob(self, context): layout.prop(ob, "nocamera") def register(): + bpy.types.Material.set_invisible = bpy.props.BoolProperty(name="Invisible") bpy.types.Material.set_collision = bpy.props.BoolProperty(name="Apply Collision Properties") bpy.types.Material.ignore = bpy.props.BoolProperty(name="ignore") bpy.types.Material.noedge = bpy.props.BoolProperty(name="No-Edge") @@ -101,7 +104,8 @@ def register(): 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_PT_custom_props.prepend(draw_func) - + + bpy.types.Object.set_invisible = bpy.props.BoolProperty(name="Invisible") bpy.types.Object.set_collision = bpy.props.BoolProperty(name="Apply Collision Properties") bpy.types.Object.ignore = bpy.props.BoolProperty(name="ignore") bpy.types.Object.noedge = bpy.props.BoolProperty(name="No-Edge") diff --git a/goalc/build_level/gltf_mesh_extract.cpp b/goalc/build_level/gltf_mesh_extract.cpp index a3cf50a300..6e7767d3be 100644 --- a/goalc/build_level/gltf_mesh_extract.cpp +++ b/goalc/build_level/gltf_mesh_extract.cpp @@ -522,14 +522,17 @@ void extract(const Input& in, for (const auto& n : all_nodes) { const auto& node = model.nodes[n.node_idx]; + if (node.extras.Has("set_invisible") && node.extras.Get("set_invisible").Get()) { + continue; + } if (node.mesh >= 0) { const auto& mesh = model.meshes[node.mesh]; - if (!mesh.extras.Has("tfrag")) { - // fmt::print("skip tfrag: {}\n", mesh.name); - // continue; - } mesh_count++; for (const auto& prim : mesh.primitives) { + if (model.materials[prim.material].extras.Has("set_invisible") && + model.materials[prim.material].extras.Get("set_invisible").Get()) { + continue; + } prim_count++; // extract index buffer std::vector prim_indices = gltf_index_buffer(model, prim.indices, out.vertices.size());