diff --git a/hecl/blender/hecl/__init__.py b/hecl/blender/hecl/__init__.py index fe4cb7ecf..ec9f7e3eb 100644 --- a/hecl/blender/hecl/__init__.py +++ b/hecl/blender/hecl/__init__.py @@ -20,6 +20,7 @@ from mathutils import Vector hecl_typeS = [ ('NONE', "None", "Active scene not using HECL", None), ('MESH', "Mesh", "Active scene represents an HMDL Mesh", hmdl.draw), +('CMESH', "Collision Mesh", "Active scene represents a Collision Mesh", None), ('ACTOR', "Actor", "Active scene represents a HECL Actor", sact.draw), ('AREA', "Area", "Active scene represents a HECL Area", srea.draw), ('WORLD', "World", "Active scene represents a HECL World", swld.draw), diff --git a/hecl/blender/hecl_blendershell.py b/hecl/blender/hecl_blendershell.py index 7fd425697..3a1674044 100644 --- a/hecl/blender/hecl_blendershell.py +++ b/hecl/blender/hecl_blendershell.py @@ -235,6 +235,19 @@ def dataout_loop(): writepipestr(b'OK') hecl.hmdl.cookcol(writepipebuf, bpy.data.objects[meshName]) + elif cmdargs[0] == 'MESHCOMPILECOLLISIONALL': + writepipestr(b'OK') + colCount = 0 + for obj in bpy.context.scene.objects: + if obj.type == 'MESH' and not obj.library: + colCount += 1 + + writepipebuf(struct.pack('I', colCount)) + + for obj in bpy.context.scene.objects: + if obj.type == 'MESH' and not obj.library: + hecl.hmdl.cookcol(writepipebuf, obj) + elif cmdargs[0] == 'MESHCOMPILEALL': maxSkinBanks = int(cmdargs[2]) maxOctantLength = float(cmdargs[3]) diff --git a/hecl/extern/boo b/hecl/extern/boo index ed9b7914e..7eb2b1961 160000 --- a/hecl/extern/boo +++ b/hecl/extern/boo @@ -1 +1 @@ -Subproject commit ed9b7914eeff6d0db2c90b34fcc3673778250ed7 +Subproject commit 7eb2b19619117c8f923d8b098e2a2d710cd3363a diff --git a/hecl/include/hecl/Blender/BlenderConnection.hpp b/hecl/include/hecl/Blender/BlenderConnection.hpp index 1f0b0dddb..4e983a78e 100644 --- a/hecl/include/hecl/Blender/BlenderConnection.hpp +++ b/hecl/include/hecl/Blender/BlenderConnection.hpp @@ -55,6 +55,7 @@ public: { None, Mesh, + ColMesh, Actor, Area, World, @@ -791,6 +792,9 @@ public: /** Compile collision mesh by name (AREA blends only) */ ColMesh compileColMesh(const std::string& name); + /** Compile all meshes as collision meshes (CMESH blends only) */ + std::vector compileColMeshes(); + /** Compile all meshes into one (AREA blends only) */ Mesh compileAllMeshes(HMDLTopology topology, int skinSlotCount=10, float maxOctantLength=5.0, Mesh::SurfProgFunc surfProg=[](int){}); diff --git a/hecl/include/hecl/hecl.hpp b/hecl/include/hecl/hecl.hpp index 0d7ca3375..52a8fb6fc 100644 --- a/hecl/include/hecl/hecl.hpp +++ b/hecl/include/hecl/hecl.hpp @@ -502,6 +502,7 @@ public: std::string toString() const {return std::string(fcc, 4);} uint32_t toUint32() const {return num;} operator uint32_t() const {return num;} + const char* getChars() const {return fcc;} }; #define FOURCC(chars) FourCC(SBIG(chars)) diff --git a/hecl/lib/Blender/BlenderConnection.cpp b/hecl/lib/Blender/BlenderConnection.cpp index 0320f083a..53f423cbf 100644 --- a/hecl/lib/Blender/BlenderConnection.cpp +++ b/hecl/lib/Blender/BlenderConnection.cpp @@ -582,6 +582,7 @@ static const char* BlendTypeStrs[] = { "NONE", "MESH", + "CMESH", "ACTOR", "AREA", "WORLD", @@ -1484,6 +1485,34 @@ BlenderConnection::DataStream::compileColMesh(const std::string& name) return ColMesh(*m_parent); } +std::vector +BlenderConnection::DataStream::compileColMeshes() +{ + if (m_parent->m_loadedType != BlendType::ColMesh) + BlenderLog.report(logvisor::Fatal, _S("%s is not a CMESH blend"), + m_parent->m_loadedBlend.getAbsolutePath().c_str()); + + char req[128]; + snprintf(req, 128, "MESHCOMPILECOLLISIONALL"); + m_parent->_writeStr(req); + + char readBuf[256]; + m_parent->_readStr(readBuf, 256); + if (strcmp(readBuf, "OK")) + BlenderLog.report(logvisor::Fatal, "unable to cook collision meshes: %s", readBuf); + + uint32_t meshCount; + m_parent->_readBuf(&meshCount, 4); + + std::vector ret; + ret.reserve(meshCount); + + for (uint32_t i=0 ; i