Skip to content

Commit 4bb00b3

Browse files
committed
slightly more stable?
1 parent c0b3747 commit 4bb00b3

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

src/Layers/xrRender/r__dsgraph_render.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ bool cmp_ssa(const T &lhs, const T &rhs)
3232
template <typename T>
3333
bool cmp_pass(const T& left, const T& right)
3434
{
35-
Msg("try cmp pass %s %s", left->first->ps->cName.c_str(), right->first->ps->cName.c_str());
3635
if (left->first->equal(*right->first))
3736
return false;
3837

39-
Msg("cmp pass ok %s %s %f %f", left->first->ps->cName.c_str(), right->first->ps->cName.c_str(), left->second.ssa, right->second.ssa);
4038
return left->second.ssa >= right->second.ssa;
4139
}
4240

src/xrGame/PhysicObject.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,30 @@ void CPhysicObject::AddElement(CPhysicsElement* root_e, int id)
382382
E->mXFORM.set(K->LL_GetTransform(u16(id)));
383383
Fobb bb = K->LL_GetBox(u16(id));
384384

385+
if (dbg_draw_doors)
386+
{
387+
const u16 bone_id = static_cast<u16>(id);
388+
CBoneData& bone_data = K->LL_GetData(bone_id);
389+
const SBoneShape& shape = bone_data.shape;
390+
const SJointIKData& joint = bone_data.IK_data;
391+
const char* bone_name = K->LL_BoneName_dbg(bone_id);
392+
Msg("[door_physics] AddElement bone='%s' id=%u parent=%p element=%p shape=%u flags=0x%X halfsize=(%.3f, %.3f, %.3f)"
393+
" joint_type=%u limits_y=(%.3f, %.3f) no_physics=%s",
394+
bone_name ? bone_name : "<unnamed>",
395+
bone_id,
396+
root_e,
397+
E,
398+
shape.type,
399+
shape.flags.get(),
400+
shape.box.m_halfsize.x,
401+
shape.box.m_halfsize.y,
402+
shape.box.m_halfsize.z,
403+
joint.type,
404+
joint.limits[1].limit.x,
405+
joint.limits[1].limit.y,
406+
shape.flags.is(SBoneShape::sfNoPhysics) ? "true" : "false");
407+
}
408+
385409
if (bb.m_halfsize.magnitude() < 0.05f)
386410
{
387411
bb.m_halfsize.add(0.05f);
@@ -414,6 +438,12 @@ void CPhysicObject::CreateBody(CSE_ALifeObjectPhysic* po)
414438
{
415439
if (m_pPhysicsShell)
416440
return;
441+
if (dbg_draw_doors)
442+
{
443+
const char* visual_name = cNameVisual().c_str();
444+
Msg("[door_physics] CreateBody start obj='%s' visual='%s' type=%d mass=%.3f", cName().c_str(),
445+
visual_name ? visual_name : "<none>", int(m_type), m_mass);
446+
}
417447
IKinematics* pKinematics = smart_cast<IKinematics*>(Visual());
418448
switch (m_type)
419449
{
@@ -429,6 +459,11 @@ void CPhysicObject::CreateBody(CSE_ALifeObjectPhysic* po)
429459
m_pPhysicsShell->set_Kinematics(pKinematics);
430460
AddElement(0, pKinematics->LL_GetBoneRoot());
431461
m_pPhysicsShell->setMass1(m_mass);
462+
if (dbg_draw_doors)
463+
{
464+
Msg("[door_physics] CreateBody built chain shell: bone_root=%u bone_count=%u", pKinematics->LL_GetBoneRoot(),
465+
pKinematics->LL_BoneCount());
466+
}
432467
}
433468
break;
434469

@@ -440,6 +475,11 @@ void CPhysicObject::CreateBody(CSE_ALifeObjectPhysic* po)
440475
break;
441476
}
442477

478+
if (dbg_draw_doors)
479+
{
480+
Msg("[door_physics] CreateBody post-switch shell=%p", m_pPhysicsShell);
481+
}
482+
443483
m_pPhysicsShell->mXFORM.set(XFORM());
444484
m_pPhysicsShell->SetAirResistance(0.001f, 0.02f);
445485
if (pKinematics)

src/xrScriptEngine/script_engine.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,18 +572,28 @@ void CScriptEngine::print_error(lua_State* L, int iErrorCode)
572572
{
573573
case LUA_ERRRUN:
574574
scriptEngine->script_log(LuaMessageType::Error, "SCRIPT RUNTIME ERROR");
575+
scriptEngine->print_stack(L);
576+
LogMemoryUsage(L, "runtime error");
575577
break;
576578
case LUA_ERRMEM:
577579
scriptEngine->script_log(LuaMessageType::Error, "SCRIPT ERROR (memory allocation)");
580+
scriptEngine->print_stack(L);
581+
LogMemoryUsage(L, "memory error");
578582
break;
579583
case LUA_ERRERR:
580584
scriptEngine->script_log(LuaMessageType::Error, "SCRIPT ERROR (while running the error handler function)");
585+
scriptEngine->print_stack(L);
586+
LogMemoryUsage(L, "error handler failure");
581587
break;
582588
case LUA_ERRFILE:
583589
scriptEngine->script_log(LuaMessageType::Error, "SCRIPT ERROR (while running file)");
590+
scriptEngine->print_stack(L);
591+
LogMemoryUsage(L, "file error");
584592
break;
585593
case LUA_ERRSYNTAX:
586594
scriptEngine->script_log(LuaMessageType::Error, "SCRIPT SYNTAX ERROR");
595+
scriptEngine->print_stack(L);
596+
LogMemoryUsage(L, "syntax error");
587597
break;
588598
case LUA_YIELD:
589599
scriptEngine->script_log(LuaMessageType::Info, "Thread is yielded");
@@ -600,6 +610,24 @@ void CScriptEngine::flush_log()
600610
m_output.save_to(log_file_name);
601611
}
602612

613+
void CScriptEngine::LogMemoryUsage(lua_State* state, pcstr reason)
614+
{
615+
if (!state)
616+
return;
617+
618+
CScriptEngine* engine = GetInstance(state);
619+
if (!engine)
620+
return;
621+
622+
const int kb = lua_gc(state, LUA_GCCOUNT, 0);
623+
const int bytes = lua_gc(state, LUA_GCCOUNTB, 0);
624+
const int total_bytes = kb * 1024 + bytes;
625+
626+
const pcstr tag = reason ? reason : "unknown";
627+
Msg("[LUA][memory] %s : %d KB + %d B (total %d bytes)", tag, kb, bytes, total_bytes);
628+
engine->script_log(LuaMessageType::Info, "[memory] %s : %d KB + %d B (total %d bytes)", tag, kb, bytes, total_bytes);
629+
}
630+
603631
CScriptEngine::CScriptEngine(bool is_editor, bool is_with_profiler)
604632
{
605633
luabind::allocator = &luabind_allocator;

src/xrScriptEngine/script_engine.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class XRSCRIPTENGINE_API CScriptEngine
194194

195195
private:
196196
static void print_error(lua_State* L, int iErrorCode);
197+
static void LogMemoryUsage(lua_State* state, pcstr reason);
197198

198199
public:
199200
static void on_error(lua_State* state);

0 commit comments

Comments
 (0)