From eb5cdf40b0ded824a8f6e4b0c94fad06d6920795 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 12 Aug 2016 09:41:51 -1000 Subject: [PATCH] Blender shell protocol fixes --- hecl/blender/BlenderConnection.hpp | 4 ++++ hecl/blender/hecl/hmdl/__init__.py | 9 ++++++++- hecl/blender/hecl_blendershell.py | 11 ++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hecl/blender/BlenderConnection.hpp b/hecl/blender/BlenderConnection.hpp index 77ff9367e..9aeeec333 100644 --- a/hecl/blender/BlenderConnection.hpp +++ b/hecl/blender/BlenderConnection.hpp @@ -395,6 +395,10 @@ public: std::unordered_map iprops; Material(BlenderConnection& conn); + bool operator==(const Material& other) const + { + return source == other.source && texs == other.texs && iprops == other.iprops; + } }; std::vector> materialSets; diff --git a/hecl/blender/hecl/hmdl/__init__.py b/hecl/blender/hecl/hmdl/__init__.py index a5677f21a..76fb470ee 100644 --- a/hecl/blender/hecl/hmdl/__init__.py +++ b/hecl/blender/hecl/hmdl/__init__.py @@ -249,7 +249,14 @@ def cookcol(writebuf, mesh_obj): for m in copy_mesh.materials: writebuf(struct.pack('I', len(m.name))) writebuf(m.name.encode()) - writebuf(struct.pack('Ib', m.retro_collision_type, m.retro_projectile_passthrough)) + cType = 0 + if 'retro_collision_type' in m: + cType = m['retro_collision_type'] + projPassthrough = False + if 'retro_projectile_passthrough' in m: + projPassthrough = m['retro_projectile_passthrough'] + + writebuf(struct.pack('Ib', cType, projPassthrough)) # Send verts writebuf(struct.pack('I', len(copy_mesh.vertices))) diff --git a/hecl/blender/hecl_blendershell.py b/hecl/blender/hecl_blendershell.py index 57d35745b..de5d917c2 100644 --- a/hecl/blender/hecl_blendershell.py +++ b/hecl/blender/hecl_blendershell.py @@ -156,8 +156,13 @@ def dataout_loop(): return elif cmdargs[0] == 'MESHLIST': + meshCount = 0 for meshobj in bpy.data.objects: - if meshobj.type == 'MESH': + if meshobj.type == 'MESH' and not meshobj.library: + meshCount += 1 + writepipebuf(struct.pack('I', meshCount)) + for meshobj in bpy.data.objects: + if meshobj.type == 'MESH' and not meshobj.library: writepipeline(meshobj.name.encode()) elif cmdargs[0] == 'MESHCOMPILE': @@ -214,7 +219,7 @@ def dataout_loop(): elif cmdargs[0] == 'LIGHTCOMPILEALL': writepipeline(b'OK') lampCount = 0; - for obj in bpy.context.scene: + for obj in bpy.context.scene.objects: if obj.type == 'LAMP': lampCount += 1 @@ -239,7 +244,7 @@ def dataout_loop(): writepipebuf(struct.pack('fff', ambient_color[0], ambient_color[1], ambient_color[2])) writepipebuf(struct.pack('IIfffffb', 0, 0, ambient_energy, 0.0, 1.0, 0.0, 0.0, False)) - for obj in bpy.context.scene: + for obj in bpy.context.scene.objects: if obj.type == 'LAMP': wmtx = obj.matrix_world writepipebuf(struct.pack('ffffffffffffffff',