From 42d39bf6b9803f395381c30c92c5e5cf3b824d17 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 11 Aug 2016 16:33:38 -1000 Subject: [PATCH] Various extract tweaks; ResourceLock integration --- DataSpec/DNACommon/CMDL.cpp | 13 +++++++++++-- DataSpec/DNACommon/CMDL.hpp | 3 ++- DataSpec/DNACommon/PAK.cpp | 6 +++++- DataSpec/DNAMP1/MREA.cpp | 2 +- DataSpec/DNAMP2/MREA.cpp | 2 +- DataSpec/DNAMP3/MREA.cpp | 2 +- hecl | 2 +- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/DataSpec/DNACommon/CMDL.cpp b/DataSpec/DNACommon/CMDL.cpp index 4f4cc59f4..6a93bfc1e 100644 --- a/DataSpec/DNACommon/CMDL.cpp +++ b/DataSpec/DNACommon/CMDL.cpp @@ -420,7 +420,8 @@ public: }; void InitGeomBlenderContext(hecl::BlenderConnection::PyOutStream& os, - const hecl::ProjectPath& masterShaderPath) + const hecl::ProjectPath& masterShaderPath, + bool solidShading) { os << "import math\n" "from mathutils import Vector\n" @@ -505,6 +506,14 @@ void InitGeomBlenderContext(hecl::BlenderConnection::PyOutStream& os, " return result\n" "\n"; + if (solidShading) + { + os << "for ar in bpy.context.screen.areas:\n" + " for sp in ar.spaces:\n" + " if sp.type == 'VIEW_3D':\n" + " sp.viewport_shade = 'SOLID'\n"; + } + /* Link master shader library */ os.format("# Master shader library\n" "with bpy.data.libraries.load('%s', link=True, relative=True) as (data_from, data_to):\n" @@ -1102,7 +1111,7 @@ bool ReadCMDLToBlender(hecl::BlenderConnection& conn, "bpy.context.scene.name = '%s'\n" "bpy.context.scene.hecl_mesh_obj = bpy.context.scene.name\n", pakRouter.getBestEntryName(entry).c_str()); - InitGeomBlenderContext(os, dataspec.getMasterShaderPath()); + InitGeomBlenderContext(os, dataspec.getMasterShaderPath(), false); MaterialSet::RegisterMaterialProps(os); os << "# Materials\n" diff --git a/DataSpec/DNACommon/CMDL.hpp b/DataSpec/DNACommon/CMDL.hpp index d59f0142b..6d4454c24 100644 --- a/DataSpec/DNACommon/CMDL.hpp +++ b/DataSpec/DNACommon/CMDL.hpp @@ -131,7 +131,8 @@ void ReadMaterialSetToBlender_3(hecl::BlenderConnection::PyOutStream& os, unsigned setIdx); void InitGeomBlenderContext(hecl::BlenderConnection::PyOutStream& os, - const hecl::ProjectPath& masterShaderPath); + const hecl::ProjectPath& masterShaderPath, + bool solidShading); void FinishBlenderMesh(hecl::BlenderConnection::PyOutStream& os, unsigned matSetCount, int meshIdx); diff --git a/DataSpec/DNACommon/PAK.cpp b/DataSpec/DNACommon/PAK.cpp index 32388104c..e4c348635 100644 --- a/DataSpec/DNACommon/PAK.cpp +++ b/DataSpec/DNACommon/PAK.cpp @@ -459,6 +459,11 @@ bool PAKRouter::extractResources(const BRIDGETYPE& pakBridge, bool f const nod::Node* node = m_node.get(); + hecl::ProjectPath working = getWorking(item, extractor); + hecl::ResourceLock resLk(working); + if (!resLk) + continue; + /* Extract first, so they start out invalid */ hecl::ProjectPath cooked = getCooked(item); if (force || cooked.getPathType() == hecl::ProjectPath::Type::None) @@ -469,7 +474,6 @@ bool PAKRouter::extractResources(const BRIDGETYPE& pakBridge, bool f fclose(fout); } - hecl::ProjectPath working = getWorking(item, extractor); if (extractor.func_a) /* Doesn't need PAKRouter access */ { if (force || working.getPathType() == hecl::ProjectPath::Type::None) diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index a472261ae..5ee62e30a 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -93,7 +93,7 @@ bool MREA::Extract(const SpecBase& dataSpec, "\n" "bpy.context.scene.name = '%s'\n", pakRouter.getBestEntryName(entry).c_str()); - DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath()); + DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" "for ob in bpy.data.objects:\n" diff --git a/DataSpec/DNAMP2/MREA.cpp b/DataSpec/DNAMP2/MREA.cpp index 719ce5220..667d57f55 100644 --- a/DataSpec/DNAMP2/MREA.cpp +++ b/DataSpec/DNAMP2/MREA.cpp @@ -223,7 +223,7 @@ bool MREA::Extract(const SpecBase& dataSpec, "\n" "bpy.context.scene.name = '%s'\n", pakRouter.getBestEntryName(entry).c_str()); - DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath()); + DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" "for ob in bpy.data.objects:\n" diff --git a/DataSpec/DNAMP3/MREA.cpp b/DataSpec/DNAMP3/MREA.cpp index b8cfd5ad0..98ae3edf8 100644 --- a/DataSpec/DNAMP3/MREA.cpp +++ b/DataSpec/DNAMP3/MREA.cpp @@ -122,7 +122,7 @@ bool MREA::Extract(const SpecBase& dataSpec, "\n" "bpy.context.scene.name = '%s'\n", pakRouter.getBestEntryName(entry).c_str()); - DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath()); + DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" "for ob in bpy.data.objects:\n" diff --git a/hecl b/hecl index c34032847..700b166ef 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit c3403284714be1dbeba736e04194af57ae6e8e17 +Subproject commit 700b166efaf9d548f1fc9e92f65894a398efee42