windows bug fixes and performance improvements

This commit is contained in:
Jack Andersen 2015-08-31 14:26:35 -10:00
parent b6c1563272
commit af2f2158bb
6 changed files with 135 additions and 15 deletions

View File

@ -146,6 +146,76 @@ public:
free(result); free(result);
} }
void linkBlend(const std::string& target, const std::string& objName, bool link=true); void linkBlend(const std::string& target, const std::string& objName, bool link=true);
class ANIMOutStream
{
BlenderConnection* m_parent;
unsigned m_curCount = 0;
unsigned m_totalCount = 0;
bool m_inCurve = false;
public:
enum CurveType
{
CurveRotate,
CurveTranslate,
CurveScale
};
ANIMOutStream(BlenderConnection* parent)
: m_parent(parent)
{
m_parent->_writeLine("PYANIM");
char readBuf[16];
m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "ANIMREADY"))
BlenderLog.report(LogVisor::FatalError, "unable to open ANIMOutStream");
}
~ANIMOutStream()
{
char tp = -1;
m_parent->_writeBuf(&tp, 1);
char readBuf[16];
m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "ANIMDONE"))
BlenderLog.report(LogVisor::FatalError, "unable to close ANIMOutStream");
}
void changeCurve(CurveType type, unsigned crvIdx, unsigned keyCount)
{
if (m_curCount != m_totalCount)
BlenderLog.report(LogVisor::FatalError, "incomplete ANIMOutStream for change");
m_curCount = 0;
m_totalCount = keyCount;
char tp = char(type);
m_parent->_writeBuf(&tp, 1);
struct
{
uint32_t ci;
uint32_t kc;
} info = {uint32_t(crvIdx), uint32_t(keyCount)};
m_parent->_writeBuf(reinterpret_cast<const char*>(&info), 8);
m_inCurve = true;
}
void write(unsigned frame, float val)
{
if (!m_inCurve)
BlenderLog.report(LogVisor::FatalError, "changeCurve not called before write");
if (m_curCount < m_totalCount)
{
struct
{
uint32_t frm;
float val;
} key = {uint32_t(frame), val};
m_parent->_writeBuf(reinterpret_cast<const char*>(&key), 8);
++m_curCount;
}
else
BlenderLog.report(LogVisor::FatalError, "ANIMOutStream keyCount overflow");
}
};
ANIMOutStream beginANIMCurve()
{
return ANIMOutStream(m_parent);
}
}; };
inline PyOutStream beginPythonOut(bool deleteOnError=false) inline PyOutStream beginPythonOut(bool deleteOnError=false)
{ {

View File

@ -1,4 +1,4 @@
import bpy, sys, os, re import bpy, sys, os, re, struct
ARGS_PATTERN = re.compile(r'''(?:"([^"]+)"|'([^']+)'|(\S+))''') ARGS_PATTERN = re.compile(r'''(?:"([^"]+)"|'([^']+)'|(\S+))''')
@ -73,6 +73,38 @@ def exec_compbuf(compbuf, globals):
co = compile(compbuf, '<HECL>', 'exec') co = compile(compbuf, '<HECL>', 'exec')
exec(co, globals) exec(co, globals)
def anim_loop(globals):
writepipeline(b'ANIMREADY')
while True:
crv_type = struct.unpack('b', os.read(readfd, 1))
if crv_type[0] < 0:
writepipeline(b'ANIMDONE')
return
elif crv_type[0] == 0:
crvs = globals['rotCurves']
elif crv_type[0] == 1:
crvs = globals['transCurves']
elif crv_type[0] == 2:
crvs = globals['scaleCurves']
key_info = struct.unpack('ii', os.read(readfd, 8))
crv = crvs[key_info[0]]
crv.keyframe_points.add(count=key_info[1])
if crv_type[0] == 1:
trans_head = globals['bone_trans_head'][key_info[0]]
for k in range(key_info[1]):
key_data = struct.unpack('if', os.read(readfd, 8))
pt = crv.keyframe_points[k]
pt.interpolation = 'LINEAR'
pt.co = (key_data[0], key_data[1] - trans_head)
else:
for k in range(key_info[1]):
key_data = struct.unpack('if', os.read(readfd, 8))
pt = crv.keyframe_points[k]
pt.interpolation = 'LINEAR'
pt.co = (key_data[0], key_data[1])
# Command loop # Command loop
while True: while True:
cmdline = readpipeline() cmdline = readpipeline()
@ -117,8 +149,17 @@ while True:
try: try:
line = readpipeline() line = readpipeline()
# ANIM check
if line == b'PYANIM':
# Ensure remaining block gets executed
if len(compbuf):
exec_compbuf(compbuf, globals)
compbuf = str()
anim_loop(globals)
continue
# End check # End check
if line == b'PYEND': elif line == b'PYEND':
# Ensure remaining block gets executed # Ensure remaining block gets executed
if len(compbuf): if len(compbuf):
exec_compbuf(compbuf, globals) exec_compbuf(compbuf, globals)

View File

@ -185,9 +185,14 @@ public:
#endif #endif
int lineIdx = 0; int lineIdx = 0;
int prevIFactor = -1;
ds.m_instance->doExtract(m_einfo, ds.m_instance->doExtract(m_einfo,
[&lineIdx](const HECL::SystemChar* message, int lidx, float factor) [&lineIdx, &prevIFactor](const HECL::SystemChar* message, int lidx, float factor)
{ {
int iFactor = factor * 100.0;
if (iFactor == prevIFactor)
return;
prevIFactor = iFactor;
#ifndef _WIN32 #ifndef _WIN32
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" HIDE_CURSOR "")); HECL::Printf(_S("" HIDE_CURSOR ""));
@ -220,7 +225,7 @@ public:
size_t blocks = half - 7; size_t blocks = half - 7;
size_t filled = blocks * factor; size_t filled = blocks * factor;
size_t rem = blocks - filled; size_t rem = blocks - filled;
HECL::Printf(_S("" BOLD "%3d%% ["), (int)(factor * 100.0)); HECL::Printf(_S("" BOLD "%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b) for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"), message); HECL::Printf(_S("#"), message);
for (int b=0 ; b<rem ; ++b) for (int b=0 ; b<rem ; ++b)
@ -233,7 +238,7 @@ public:
size_t blocks = half - 7; size_t blocks = half - 7;
size_t filled = blocks * factor; size_t filled = blocks * factor;
size_t rem = blocks - filled; size_t rem = blocks - filled;
HECL::Printf(_S("%3d%% ["), (int)(factor * 100.0)); HECL::Printf(_S("%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b) for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"), message); HECL::Printf(_S("#"), message);
for (int b=0 ; b<rem ; ++b) for (int b=0 ; b<rem ; ++b)

2
hecl/extern/Athena vendored

@ -1 +1 @@
Subproject commit bca146dbfce090d2c12773e26f4f097a3843d9c1 Subproject commit 4a4962424dc8c87c68dc9696c4c13a7e8d09d9a7

View File

@ -200,11 +200,13 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
{ {
#if HECL_UCS2 #if HECL_UCS2
FILE* fp = _wfopen(path, mode); FILE* fp = _wfopen(path, mode);
if (!fp)
LogModule.report(LogVisor::FatalError, L"fopen %s: %s", path, _wcserror(errno));
#else #else
FILE* fp = fopen(path, mode); FILE* fp = fopen(path, mode);
#endif
if (!fp) if (!fp)
LogModule.report(LogVisor::FatalError, "fopen %s: %s", path, strerror(errno)); LogModule.report(LogVisor::FatalError, "fopen %s: %s", path, strerror(errno));
#endif
if (lock) if (lock)
{ {

View File

@ -43,6 +43,8 @@ void *memmem(const void *haystack, size_t hlen, const void *needle, size_t nlen)
#include "shlguid.h" #include "shlguid.h"
#include "strsafe.h" #include "strsafe.h"
#define HECL_MAX_PATH 2048
HRESULT CreateShellLink(LPCWSTR lpszPathObj, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) HRESULT CreateShellLink(LPCWSTR lpszPathObj, LPCWSTR lpszPathLink, LPCWSTR lpszDesc)
{ {
std::wstring targetStr(lpszPathObj); std::wstring targetStr(lpszPathObj);
@ -66,13 +68,13 @@ HRESULT CreateShellLink(LPCWSTR lpszPathObj, LPCWSTR lpszPathLink, LPCWSTR lpszD
IPersistFile* ppf; IPersistFile* ppf;
// Set the path to the shortcut target and add the description. // Set the path to the shortcut target and add the description.
WCHAR targetBuf[MAX_PATH]; WCHAR targetBuf[HECL_MAX_PATH];
WCHAR linkBuf[MAX_PATH]; WCHAR linkBuf[HECL_MAX_PATH];
WCHAR* linkFinalPart = nullptr; WCHAR* linkFinalPart = nullptr;
GetFullPathNameW(linkStr.c_str(), MAX_PATH, linkBuf, &linkFinalPart); GetFullPathNameW(linkStr.c_str(), HECL_MAX_PATH, linkBuf, &linkFinalPart);
if (linkFinalPart != linkBuf) if (linkFinalPart != linkBuf)
*(linkFinalPart-1) = L'\0'; *(linkFinalPart-1) = L'\0';
StringCbPrintfW(targetBuf, MAX_PATH, L"%s\\%s", linkBuf, targetStr.c_str()); StringCbPrintfW(targetBuf, HECL_MAX_PATH, L"%s\\%s", linkBuf, targetStr.c_str());
if (linkFinalPart != linkBuf) if (linkFinalPart != linkBuf)
*(linkFinalPart - 1) = L'\\'; *(linkFinalPart - 1) = L'\\';
psl->SetPath(targetBuf); psl->SetPath(targetBuf);
@ -98,8 +100,8 @@ HRESULT ResolveShellLink(LPCWSTR lpszLinkFile, LPWSTR lpszPath, int iPathBufferS
{ {
HRESULT hres; HRESULT hres;
IShellLink* psl; IShellLink* psl;
WCHAR szGotPath[MAX_PATH]; WCHAR szGotPath[HECL_MAX_PATH];
WCHAR szDescription[MAX_PATH]; WCHAR szDescription[HECL_MAX_PATH];
WIN32_FIND_DATA wfd; WIN32_FIND_DATA wfd;
*lpszPath = 0; // Assume failure *lpszPath = 0; // Assume failure
@ -130,12 +132,12 @@ HRESULT ResolveShellLink(LPCWSTR lpszLinkFile, LPWSTR lpszPath, int iPathBufferS
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
// Get the path to the link target. // Get the path to the link target.
hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA*)&wfd, SLGP_SHORTPATH); hres = psl->GetPath(szGotPath, HECL_MAX_PATH, (WIN32_FIND_DATA*)&wfd, SLGP_SHORTPATH);
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
// Get the description of the target. // Get the description of the target.
hres = psl->GetDescription(szDescription, MAX_PATH); hres = psl->GetDescription(szDescription, HECL_MAX_PATH);
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {