mirror of https://github.com/AxioDL/metaforce.git
BlenderConnection tweaks
This commit is contained in:
parent
4f53d886ce
commit
e65fe14c53
|
@ -1,4 +1,4 @@
|
||||||
import bpy
|
import bpy, struct
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
|
|
||||||
def build_dock_connections():
|
def build_dock_connections():
|
||||||
|
@ -44,9 +44,9 @@ def cook(writebuf):
|
||||||
writebuf(struct.pack('I', len(obj.name)))
|
writebuf(struct.pack('I', len(obj.name)))
|
||||||
writebuf(obj.name.encode())
|
writebuf(obj.name.encode())
|
||||||
|
|
||||||
pt = Vector(copy_obj.bound_box[0])
|
pt = Vector(obj.bound_box[0])
|
||||||
writebuf(struct.pack('fff', pt[0], pt[1], pt[2]))
|
writebuf(struct.pack('fff', pt[0], pt[1], pt[2]))
|
||||||
pt = Vector(copy_obj.bound_box[6])
|
pt = Vector(obj.bound_box[6])
|
||||||
writebuf(struct.pack('fff', pt[0], pt[1], pt[2]))
|
writebuf(struct.pack('fff', pt[0], pt[1], pt[2]))
|
||||||
|
|
||||||
wmtx = obj.matrix_world
|
wmtx = obj.matrix_world
|
||||||
|
@ -67,7 +67,8 @@ def cook(writebuf):
|
||||||
v = wmtx * ch.data.vertices[vi].co
|
v = wmtx * ch.data.vertices[vi].co
|
||||||
writebuf(struct.pack('fff', v[0], v[1], v[2]))
|
writebuf(struct.pack('fff', v[0], v[1], v[2]))
|
||||||
conn_dock = dock_conns[ch.name]
|
conn_dock = dock_conns[ch.name]
|
||||||
writebuf(struct.pack('II', conn_dock[0], conn_dock[1]))
|
writebuf(struct.pack('I', conn_dock[0]))
|
||||||
|
writebuf(struct.pack('I', conn_dock[1]))
|
||||||
|
|
||||||
|
|
||||||
# Panel draw
|
# Panel draw
|
||||||
|
|
|
@ -291,6 +291,21 @@ def dataout_loop():
|
||||||
writepipebuf(struct.pack('IIfffffb', layer, type, obj.data.energy, spotCutoff, constant, linear, quadratic,
|
writepipebuf(struct.pack('IIfffffb', layer, type, obj.data.energy, spotCutoff, constant, linear, quadratic,
|
||||||
castShadow))
|
castShadow))
|
||||||
|
|
||||||
|
elif cmdargs[0] == 'GETTEXTURES':
|
||||||
|
writepipeline(b'OK')
|
||||||
|
|
||||||
|
img_count = 0
|
||||||
|
for img in bpy.data.images:
|
||||||
|
if img.type == 'IMAGE':
|
||||||
|
img_count += 1
|
||||||
|
writepipebuf(struct.pack('I', img_count))
|
||||||
|
|
||||||
|
for img in bpy.data.images:
|
||||||
|
if img.type == 'IMAGE':
|
||||||
|
path = os.path.normpath(bpy.path.abspath(img.filepath))
|
||||||
|
writepipebuf(struct.pack('I', len(path)))
|
||||||
|
writepipebuf(path.encode())
|
||||||
|
|
||||||
elif cmdargs[0] == 'ACTORCOMPILE':
|
elif cmdargs[0] == 'ACTORCOMPILE':
|
||||||
writepipeline(b'OK')
|
writepipeline(b'OK')
|
||||||
hecl.sact.cook(writepipebuf)
|
hecl.sact.cook(writepipebuf)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d3d63082d0087e2f85ee3bd43d27f077f40f6ebf
|
Subproject commit b3ca9a0a9023580db5dff68158606a64841b7f4e
|
|
@ -658,6 +658,9 @@ public:
|
||||||
/** Gather all lights in scene (AREA blends only) */
|
/** Gather all lights in scene (AREA blends only) */
|
||||||
std::vector<Light> compileLights();
|
std::vector<Light> compileLights();
|
||||||
|
|
||||||
|
/** Gather all texture paths in scene */
|
||||||
|
std::vector<ProjectPath> getTextures();
|
||||||
|
|
||||||
/** Intermediate actor representation prepared by blender from a single HECL actor blend */
|
/** Intermediate actor representation prepared by blender from a single HECL actor blend */
|
||||||
struct Actor
|
struct Actor
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,9 +132,6 @@ public:
|
||||||
virtual bool canPackage(const PackagePassInfo& info,
|
virtual bool canPackage(const PackagePassInfo& info,
|
||||||
SystemString& reasonNo)
|
SystemString& reasonNo)
|
||||||
{(void)info;reasonNo=_S("not implemented");return false;}
|
{(void)info;reasonNo=_S("not implemented");return false;}
|
||||||
virtual void gatherDependencies(const PackagePassInfo& info,
|
|
||||||
std::unordered_set<ProjectPath>& implicitsOut)
|
|
||||||
{(void)info;(void)implicitsOut;}
|
|
||||||
virtual void doPackage(const PackagePassInfo& info)
|
virtual void doPackage(const PackagePassInfo& info)
|
||||||
{(void)info;}
|
{(void)info;}
|
||||||
|
|
||||||
|
@ -273,6 +270,7 @@ private:
|
||||||
ProjectPath m_dotPath;
|
ProjectPath m_dotPath;
|
||||||
ProjectPath m_cookedRoot;
|
ProjectPath m_cookedRoot;
|
||||||
std::vector<ProjectDataSpec> m_compiledSpecs;
|
std::vector<ProjectDataSpec> m_compiledSpecs;
|
||||||
|
std::unordered_map<uint64_t, ProjectPath> m_bridgePathCache;
|
||||||
bool m_valid = false;
|
bool m_valid = false;
|
||||||
public:
|
public:
|
||||||
Project(const hecl::ProjectRootPath& rootPath);
|
Project(const hecl::ProjectRootPath& rootPath);
|
||||||
|
@ -455,6 +453,21 @@ public:
|
||||||
*/
|
*/
|
||||||
PackageDepsgraph buildPackageDepsgraph(const ProjectPath& path);
|
PackageDepsgraph buildPackageDepsgraph(const ProjectPath& path);
|
||||||
|
|
||||||
|
/** Add ProjectPath to bridge cache */
|
||||||
|
void addBridgePathToCache(uint64_t id, const ProjectPath& path) { m_bridgePathCache[id] = path; }
|
||||||
|
|
||||||
|
/** Clear all ProjectPaths in bridge cache */
|
||||||
|
void clearBridgePathCache() { m_bridgePathCache.clear(); }
|
||||||
|
|
||||||
|
/** Lookup ProjectPath from bridge cache */
|
||||||
|
const ProjectPath* lookupBridgePath(uint64_t id) const
|
||||||
|
{
|
||||||
|
auto search = m_bridgePathCache.find(id);
|
||||||
|
if (search == m_bridgePathCache.cend())
|
||||||
|
return nullptr;
|
||||||
|
return &search->second;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1332,6 +1332,35 @@ std::vector<BlenderConnection::DataStream::Light> BlenderConnection::DataStream:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<ProjectPath> BlenderConnection::DataStream::getTextures()
|
||||||
|
{
|
||||||
|
m_parent->_writeLine("GETTEXTURES");
|
||||||
|
|
||||||
|
char readBuf[256];
|
||||||
|
m_parent->_readLine(readBuf, 256);
|
||||||
|
if (strcmp(readBuf, "OK"))
|
||||||
|
BlenderLog.report(logvisor::Fatal, "unable to get textures: %s", readBuf);
|
||||||
|
|
||||||
|
uint32_t texCount;
|
||||||
|
m_parent->_readBuf(&texCount, 4);
|
||||||
|
std::vector<ProjectPath> texs;
|
||||||
|
texs.reserve(texCount);
|
||||||
|
for (uint32_t i=0 ; i<texCount ; ++i)
|
||||||
|
{
|
||||||
|
uint32_t bufSz;
|
||||||
|
m_parent->_readBuf(&bufSz, 4);
|
||||||
|
std::string readStr(bufSz, ' ');
|
||||||
|
m_parent->_readBuf(&readStr[0], bufSz);
|
||||||
|
SystemStringView absolute(readStr);
|
||||||
|
|
||||||
|
SystemString relative =
|
||||||
|
m_parent->m_loadedBlend.getProject().getProjectRootPath().getProjectRelativeFromAbsolute(absolute);
|
||||||
|
texs.emplace_back(m_parent->m_loadedBlend.getProject().getProjectWorkingPath(), relative);
|
||||||
|
}
|
||||||
|
|
||||||
|
return texs;
|
||||||
|
}
|
||||||
|
|
||||||
BlenderConnection::DataStream::Actor BlenderConnection::DataStream::compileActor()
|
BlenderConnection::DataStream::Actor BlenderConnection::DataStream::compileActor()
|
||||||
{
|
{
|
||||||
if (m_parent->m_loadedType != BlendType::Actor)
|
if (m_parent->m_loadedType != BlendType::Actor)
|
||||||
|
|
Loading…
Reference in New Issue