More mesh cooking bug fixes

This commit is contained in:
Jack Andersen 2015-10-03 19:08:24 -10:00
parent 051e16fdee
commit f78aa15980
6 changed files with 43 additions and 42 deletions

View File

@ -366,26 +366,12 @@ bool BlenderConnection::createBlend(const SystemString& path, BlendType type)
if (!strcmp(lineBuf, "FINISHED")) if (!strcmp(lineBuf, "FINISHED"))
{ {
m_loadedBlend = path; m_loadedBlend = path;
m_loadedType = type;
return true; return true;
} }
return false; return false;
} }
BlenderConnection::BlendType BlenderConnection::getBlendType()
{
_writeLine("GETTYPE");
char lineBuf[256];
_readLine(lineBuf, sizeof(lineBuf));
unsigned idx = 0;
while (BlendTypeStrs[idx])
{
if (!strcmp(BlendTypeStrs[idx], lineBuf))
return BlendType(idx);
++idx;
}
return TypeNone;
}
bool BlenderConnection::openBlend(const SystemString& path) bool BlenderConnection::openBlend(const SystemString& path)
{ {
if (m_lock) if (m_lock)
@ -403,6 +389,19 @@ bool BlenderConnection::openBlend(const SystemString& path)
if (!strcmp(lineBuf, "FINISHED")) if (!strcmp(lineBuf, "FINISHED"))
{ {
m_loadedBlend = path; m_loadedBlend = path;
_writeLine("GETTYPE");
_readLine(lineBuf, sizeof(lineBuf));
m_loadedType = TypeNone;
unsigned idx = 0;
while (BlendTypeStrs[idx])
{
if (!strcmp(BlendTypeStrs[idx], lineBuf))
{
m_loadedType = BlendType(idx);
break;
}
++idx;
}
return true; return true;
} }
return false; return false;
@ -487,12 +486,16 @@ BlenderConnection::DataStream::Mesh::Mesh(BlenderConnection& conn, int skinSlotC
norm.emplace_back(conn); norm.emplace_back(conn);
conn._readBuf(&colorLayerCount, 4); conn._readBuf(&colorLayerCount, 4);
if (colorLayerCount > 4)
LogModule.report(LogVisor::FatalError, "mesh has %u color-layers; max 4", colorLayerCount);
conn._readBuf(&count, 4); conn._readBuf(&count, 4);
color.reserve(count); color.reserve(count);
for (int i=0 ; i<count ; ++i) for (int i=0 ; i<count ; ++i)
color.emplace_back(conn); color.emplace_back(conn);
conn._readBuf(&uvLayerCount, 4); conn._readBuf(&uvLayerCount, 4);
if (uvLayerCount > 8)
LogModule.report(LogVisor::FatalError, "mesh has %u UV-layers; max 8", uvLayerCount);
conn._readBuf(&count, 4); conn._readBuf(&count, 4);
uv.reserve(count); uv.reserve(count);
for (int i=0 ; i<count ; ++i) for (int i=0 ; i<count ; ++i)
@ -595,13 +598,11 @@ BlenderConnection::DataStream::Mesh::Surface::Vert::Vert
{ {
conn._readBuf(&iPos, 4); conn._readBuf(&iPos, 4);
conn._readBuf(&iNorm, 4); conn._readBuf(&iNorm, 4);
if (parent.colorLayerCount) for (int i=0 ; i<parent.colorLayerCount ; ++i)
conn._readBuf(iColor, 4 * parent.colorLayerCount); conn._readBuf(&iColor[i], 4);
if (parent.uvLayerCount) for (int i=0 ; i<parent.uvLayerCount ; ++i)
conn._readBuf(iUv, 4 * parent.uvLayerCount); conn._readBuf(&iUv[i], 4);
conn._readBuf(&iSkin, 4); conn._readBuf(&iSkin, 4);
if (parent.pos.size() == 1250)
printf("");
} }
static bool VertInBank(const std::vector<uint32_t>& bank, uint32_t sIdx) static bool VertInBank(const std::vector<uint32_t>& bank, uint32_t sIdx)

View File

@ -28,6 +28,15 @@ extern class BlenderConnection* SharedBlenderConnection;
class BlenderConnection class BlenderConnection
{ {
public:
enum BlendType
{
TypeNone,
TypeMesh,
TypeActor,
TypeArea
};
private:
bool m_lock = false; bool m_lock = false;
#if _WIN32 #if _WIN32
HANDLE m_blenderProc; HANDLE m_blenderProc;
@ -36,6 +45,7 @@ class BlenderConnection
#endif #endif
int m_readpipe[2]; int m_readpipe[2];
int m_writepipe[2]; int m_writepipe[2];
BlendType m_loadedType = TypeNone;
SystemString m_loadedBlend; SystemString m_loadedBlend;
std::string m_startupBlend; std::string m_startupBlend;
size_t _readLine(char* buf, size_t bufSz); size_t _readLine(char* buf, size_t bufSz);
@ -47,16 +57,8 @@ public:
BlenderConnection(int verbosityLevel=1); BlenderConnection(int verbosityLevel=1);
~BlenderConnection(); ~BlenderConnection();
enum BlendType
{
TypeNone,
TypeMesh,
TypeActor,
TypeArea
};
bool createBlend(const SystemString& path, BlendType type); bool createBlend(const SystemString& path, BlendType type);
BlendType getBlendType(); BlendType getBlendType() const {return m_loadedType;}
bool openBlend(const SystemString& path); bool openBlend(const SystemString& path);
bool saveBlend(); bool saveBlend();
void deleteBlend(); void deleteBlend();

View File

@ -122,7 +122,6 @@ class VertPool:
for ul in range(len(self.ulays)): for ul in range(len(self.ulays)):
writebuffunc(struct.pack('I', self.get_uv_idx(loop, ul))) writebuffunc(struct.pack('I', self.get_uv_idx(loop, ul)))
sp = struct.pack('I', self.get_skin_idx(loop.vert)) sp = struct.pack('I', self.get_skin_idx(loop.vert))
print(sp)
writebuffunc(sp) writebuffunc(sp)
def recursive_faces_islands(dlay, list_out, rem_list, skin_slot_set, skin_slot_count, face): def recursive_faces_islands(dlay, list_out, rem_list, skin_slot_set, skin_slot_count, face):
@ -273,7 +272,6 @@ def write_out_surface(writebuffunc, vert_pool, island_faces, mat_idx):
# Count estimate # Count estimate
writebuffunc(struct.pack('I', len(island_faces) * 3)) writebuffunc(struct.pack('I', len(island_faces) * 3))
print('EST', len(island_faces) * 3)
# Verts themselves # Verts themselves
last_loop = None last_loop = None

View File

@ -79,14 +79,14 @@ def recursive_color_trace(mat_obj, mesh_obj, tex_list, node, socket=None):
soc = soc_from.node.inputs[s+1] soc = soc_from.node.inputs[s+1]
if len(soc.links): if len(soc.links):
raise RuntimeError("UV Modifier nodes may not have parameter links (default values only)") raise RuntimeError("UV Modifier nodes may not have parameter links (default values only)")
ncomps = len(soc.default_value) if soc.type == 'VALUE':
if ncomps > 1: matrix_str += '%g' % soc.default_value
else:
ncomps = len(soc.default_value)
matrix_str += 'vec%d(' % ncomps matrix_str += 'vec%d(' % ncomps
for c in ncomps-1: for c in ncomps-1:
matrix_str += '%g, ' % soc.default_value[c] matrix_str += '%g, ' % soc.default_value[c]
matrix_str += '%g)' % soc.default_value[ncomps-1] matrix_str += '%g)' % soc.default_value[ncomps-1]
else:
matrix_str += '%g' % soc.default_value
if s == len(soc_from.node.inputs)-2: if s == len(soc_from.node.inputs)-2:
matrix_str += ')' matrix_str += ')'
@ -223,14 +223,14 @@ def recursive_alpha_trace(mat_obj, mesh_obj, tex_list, node, socket=None):
soc = soc_from.node.inputs[s+1] soc = soc_from.node.inputs[s+1]
if len(soc.links): if len(soc.links):
raise RuntimeError("UV Modifier nodes may not have parameter links (default values only)") raise RuntimeError("UV Modifier nodes may not have parameter links (default values only)")
ncomps = len(soc.default_value) if soc.type == 'VALUE':
if ncomps > 1: matrix_str += '%g' % soc.default_value
else:
ncomps = len(soc.default_value)
matrix_str += 'vec%d(' % ncomps matrix_str += 'vec%d(' % ncomps
for c in ncomps-1: for c in ncomps-1:
matrix_str += '%g, ' % soc.default_value[c] matrix_str += '%g, ' % soc.default_value[c]
matrix_str += '%g)' % soc.default_value[ncomps-1] matrix_str += '%g)' % soc.default_value[ncomps-1]
else:
matrix_str += '%g' % soc.default_value
if s == len(soc_from.node.inputs)-2: if s == len(soc_from.node.inputs)-2:
matrix_str += ')' matrix_str += ')'

View File

@ -24,7 +24,7 @@ def readpipeline():
retval += ch retval += ch
def writepipeline(linebytes): def writepipeline(linebytes):
print('LINE', linebytes) #print('LINE', linebytes)
os.write(writefd, linebytes + b'\n') os.write(writefd, linebytes + b'\n')
def writepipebuf(linebytes): def writepipebuf(linebytes):

View File

@ -180,7 +180,7 @@ Time ProjectPath::getModtime() const
return Time(latestTime); return Time(latestTime);
} }
} }
LogModule.report(LogVisor::Error, _S("invalid path type for computing modtime in '%s'"), m_absPath.c_str()); LogModule.report(LogVisor::FatalError, _S("invalid path type for computing modtime in '%s'"), m_absPath.c_str());
return Time(); return Time();
} }