U32 Mesh::Manager::Report() { U32 countT = 0, memT = 0; NBinTree<MeshRoot>::Iterator ri(&rootTree); while (MeshRoot * root = ri++) { if (!root->isChunk) { memT += root->GetMem(); countT++; } } U32 countE = 0, memE = 0; NList<MeshEnt>::Iterator ei(&entList); while (MeshEnt * ent = ei++) { memE += ent->GetMem(); countE++; } U32 mem = memT + memE + endVar - startVar; // namespace CON_DIAG( ("%4d %-31s: %9d", countT, "mesh types", memT ) ); LOG_DIAG( ("%4d %-31s: %9d", countT, "mesh types", memT ) ); CON_DIAG( ("%4d %-31s: %9d", countE, "mesh instances", memE ) ); LOG_DIAG( ("%4d %-31s: %9d", countE, "mesh instances", memE ) ); return mem; }
U32 Mesh::Manager::ReportList( const char * name) // = NULL { U32 count = 0; U32 len = 0, hit = FALSE; if ( name) { len = strlen( name); } else { hit = TRUE; } U32 mem = 0; remem = recount = rgeo = ranim = rmrm = 0; NBinTree<MeshRoot>::Iterator li(&rootTree); while (MeshRoot * root = li++) { if (!root->isChunk && (!name || !strnicmp( root->fileName.str, name, len))) { mem += Report( *root); hit = TRUE; count++; } } if (hit) { CON_DIAG( ("%4ld %-31s: %9ld g%6ld a%6ld m%6ld", count, "mesh types", mem, rgeo, ranim, rmrm )); LOG_DIAG( ("%4ld %-31s: %9ld g%6ld a%6ld m%6ld", count, "mesh types", mem, rgeo, ranim, rmrm )); CON_DIAG( ("%4ld %-31s: %9ld", recount, "mesh instances", remem ) ); LOG_DIAG( ("%4ld %-31s: %9ld", recount, "mesh instances", remem ) ); } else { CON_DIAG( ("Can't find mesh type: %s", name) ); } return mem + remem; }
/////////////////////////////////////////////////////////////////////////////// // // Quake::CmdHandler // void CmdHandler(U32 pathCrc) { switch (pathCrc) { case 0x3860F45E: // "quake.active" if (*active) { effect->StopByEffect(); effect->Play2D(Sound::Digital::DEFAULT_VOLUME, Sound::Digital::NO_OWNER, F32_MAX, 0); soundoff = FALSE; quakeAnim.SetFrame(0); } else { effect->StopByEffect(); soundoff = TRUE; } break; case 0x030664FD: // "quake.type" { Type * t = typeList.Find( Crc::CalcStr( *typeVar)); if (t) { SetCurrent( t); } break; } case 0x44327F38: // "quake.listtypes" { char *s = NULL; Console::GetArgString(1, s); U32 len = 0; if (s) { len = strlen(s); } // Registered quake types CON_DIAG(("[Quake Types]")) BinTree<Type>::Iterator i(&typeList); for (!i; *i; i++) { if (!s || !Utils::Strnicmp( (*i)->name.str, s, len)) { Console::Message("%s", (*i)->name.str); } } break; } // } // switch( pathCrc) }
U32 FamilyNode::GetHierarchy( BuffString *names, U32 &count, Bool local, U32 tabCount, Matrix * matrix) const // = FALSE, = 0, = NULL { if (count >= MAXMESHPERGROUP) { return count; } BuffString buff; char *p = buff.str; U32 i; for (i = 0; i < tabCount; i++) { *p++ = ' '; } Utils::Strcpy( p, name.str); if (names) { names[count] = buff.str; } else { if (matrix) { CON_DIAG(("")); LOG_DIAG(("")); } CON_DIAG( ("%s", buff.str) ); LOG_DIAG( ("%s", buff.str) ); if (matrix) { *p = '\0'; CON_DIAG(("%sright %f,%f,%f", buff.str, matrix->right.x, matrix->right.y, matrix->right.z)); CON_DIAG(("%sup %f,%f,%f", buff.str, matrix->up.x, matrix->up.y, matrix->up.z)); CON_DIAG(("%sfront %f,%f,%f", buff.str, matrix->front.x, matrix->front.y, matrix->front.z)); CON_DIAG(("%sposit %f,%f,%f", buff.str, matrix->posit.x, matrix->posit.y, matrix->posit.z)); LOG_DIAG(("%sright %f,%f,%f", buff.str, matrix->right.x, matrix->right.y, matrix->right.z)); LOG_DIAG(("%sup %f,%f,%f", buff.str, matrix->up.x, matrix->up.y, matrix->up.z)); LOG_DIAG(("%sfront %f,%f,%f", buff.str, matrix->front.x, matrix->front.y, matrix->front.z)); LOG_DIAG(("%sposit %f,%f,%f", buff.str, matrix->posit.x, matrix->posit.y, matrix->posit.z)); } } Matrix newMatrix; if (matrix) { if (count > 0) { *matrix = ObjectMatrix() * *matrix; } newMatrix = *matrix; } count++; NList<FamilyNode>::Iterator kids(&children); FamilyNode *node; while ((node = kids++) != NULL) { if (local && node->nodeType != nodeMesh && node->nodeType != nodeMeshObj) { continue; } if (matrix) { *matrix = newMatrix; } tabCount++; node->GetHierarchy( names, count, local, tabCount, matrix); tabCount--; } return count; }
// // CmdHandler // // Handles all global level console commands // static void CmdHandler(U32 pathCrc) { switch (pathCrc) { // // Root level commands // case 0xB4729720: // "quit" runCodes.Set("QUIT"); break; #ifdef DEVELOPMENT case 0xBC36982D: // "ls" { U32 flags = Console::SHOWSCOPES | Console::SHOWVARS | Console::SHOWCMDS; // Recurse if there are any args ;) if (Console::ArgCount() == 1) { flags |= Console::NORECURSE; } Console::DisplayVarScope(VarSys::gScope, 0, flags); break; } #endif case 0xC39EE127: // "op" { const char *var, *op; VarSys::VarItem *param; if (Console::GetArgString(1, var) && Console::GetArgString(2, op) && Console::GetArg(3, param)) { Operation::Console(var, op, param); } else { CON_ERR((Console::ARGS)) } break; } case 0x5D8A9066: // "?" case 0xFF52E6E7: // "help" CON_DIAG(("Commands at the global scope :")) Console::DisplayVarScope(VarSys::gScope, 0, Console::SHOWCMDS); break; case 0x4CE2B3B3: // "bind" { const char *s1 = NULL, *s2; // If one argument is provided then print the binding for that item if (Console::GetArgString(1, s1)) { if (Console::GetArgString(2, s2)) { // Bind the key KeyBind::Create(s1, s2); break; } } // Print the binding KeyBind::Dump(KeyBind::DUMP_PRESS | KeyBind::DUMP_HOLD, s1); break; } case 0x3E3AF310: // "unbind" { const char *s; if (!Console::GetArgString(1, s)) { CON_ERR((Console::ARGS)) } else { // Unbind the key KeyBind::Remove(s); } break; } case 0xAAD665AB: // "exec" { const char *name; if (Console::GetArgString(1, name)) { if (!Exec(name, ScopeHandler, FALSE)) { CON_ERR(("Unable to exec file '%s' (not found)", name)) } } else { CON_ERR((Console::ARGS)) } break; } case 0x93890429: // "echo" { const char *str; if (Console::GetArgString(1, str)) { CON_MSG((str)) } break; } // // System commands // case 0x2AF1E6BC: // "sys.info" CON_DIAG(("CPU: %s", Hardware::CPU::GetDetailedDesc())) CON_DIAG(("MEM: %s", Hardware::Memory::GetDesc())) CON_DIAG(("OS : %s", Hardware::OS::GetDesc())) break; case 0x65CDFB1A: // "sys.uptime" CON_ERR(("I fell off my bike and hurt my knee :(")) break; case 0x9FE06237: // "sys.profile" break; case 0x1C3D54FD: // "sys.ver" CON_DIAG((Version::GetBuildString())) CON_DIAG(("Compiler flags: %s", Version::GetBuildDefs())) CON_DIAG(("Compiled by %s\\%s on %s", Version::GetBuildMachine(), Version::GetBuildUser(), Version::GetBuildOS())) CON_DIAG(("Executed by %s\\%s on %s", Hardware::OS::GetComputer(), Hardware::OS::GetUser(), Hardware::OS::GetDesc())) break; case 0x27988902: // "sys.runcode" { const char *s; if (Console::ArgCount() == 2 && Console::GetArgString(1, s)) { runCodes.Set(s); } else { CON_ERR((Console::ARGS)) } break; } case 0x94908FF0: // "sys.runonce" { const char *s; if (Console::GetArgString(1, s)) { AddRunOnceCmd(s); } else { CON_ERR((Console::ARGS)) } break; } case 0xEBB16C2F: // "sys.buildfileindexes" FileSys::BuildIndexes(); break; // // Profile commands // case 0xC20C046F: // "profile.init" { S32 max; S32 interval; if (!Console::GetArgInteger(1, max) || !Console::GetArgInteger(2, interval)) { CON_ERR(("profile.init max interval")) } else { Profile::Init(max, interval); profileOn = TRUE; } break; } case 0x484CCBF7: // "profile.reset" if (!profileOn) { CON_ERR(("Profiling is not initialized, use profile.init")) } else { Profile::Reset(); } break; case 0x139D6F79: // "profile.start" if (!profileOn) { CON_ERR(("Profiling is not initialized, use profile.init")) } else { Profile::Start(); } break; case 0x96C4A523: // "profile.stop" if (!profileOn) { CON_ERR(("Profiling is not initialized, use profile.init")) } else { Profile::Stop(); } break; // // Debug commands // case 0x7C6C010C: // "debug.break" DebugBreak(); break; case 0xE7123308: // "debug.assert" { CON_DIAG(("Calling ASSERT(0)")) Bool fatal = 0; fatal; ASSERT(fatal); break; } case 0x406C755D: // "debug.stackoverflow" CmdHandler(0x406C755D); break; case 0x019C9670: // "debug.filesys" CON_DIAG(("Logging all file sources")) FileSys::LogAllSources(); break; case 0x72E8EE93: // "debug.infiniteloop" { for (;;) { } } case 0xB67F90C3: // "debug.loop" { S32 time; if (Console::GetArgInteger(1, time) && (time > 0)) { U32 start = Clock::Time::Ms(); for (;;) { if (Clock::Time::Ms() > (start + U32(time))) { break; } } } break; } case 0x329B7354: // "debug.zerodiv" { Utils::FP::UnmaskException(Utils::FP::EX_ZERODIVIDE); F32 a = 0.0F; F32 b = 5.0F / a; b; break; } case 0x9C3DECF8: // "debug.intzerodiv" { S32 a = 0; S32 b = 5 / a; b; break; } case 0x0C887FB2: // "debug.overflow" { Utils::FP::UnmaskException(Utils::FP::EX_OVERFLOW); F32 a = F32_MAX; a *= 2.0F; break; } case 0x3B8C9F71: // "debug.underflow" { Utils::FP::UnmaskException(Utils::FP::EX_UNDERFLOW); F32 a = F32_EPSILON; a *= F32_EPSILON; break; } case 0x4A533750: // "debug.dircrc" { // Dump Directory Crc U32 crc = Dir::Crc(".\\packs"); CON_DIAG(("Data Crc: [%08X]", crc)) break; } case 0xD30DA7AC: // "debug.dumpsymbols" Debug::Symbol::Dump(); break; case 0x21237FCF: // "debug.memory.accessviolation" { U8 *p = NULL; *(p+0xFFFFFFFF) = 0; break; } case 0xF0BA78F5: // "debug.memory.overwritehead" { U8 *p = new U8[24]; *(p - 2) = 0x00; delete p; break; } case 0x29939DAF: // "debug.memory.overwritetail" { U8 *p = new U8[24]; *(p + 26) = 0x00; delete p; break; } case 0x1C7E4D06: // "debug.memory.useall" { U32 meg = 0; for (;;) { char *mem = new char[1048576 * 5]; memset(mem, 0, 1048576 * 5); meg+=5; LOG_DIAG(("Allocated %d megs", meg)); } break; } case 0x137FF882: // "debug.memory.snapshot" { Debug::Memory::SnapShot(); break; } case 0x24D608EF: // "debug.memory.report" { CON_DIAG(("Memory Report")) CON_DIAG(("-------------")) CON_DIAG(("Current Memory Usage:")) CON_DIAG(("Allocated Blocks : %d", Debug::Memory::GetAllocatedBlocks())) CON_DIAG(("Allocated Bytes : %d", Debug::Memory::GetAllocatedBytes())) CON_DIAG(("Overhead Bytes : %d", Debug::Memory::GetOverheadBytes())) CON_DIAG(("Cache Blocks : %d", Debug::Memory::GetCacheBlocks())) CON_DIAG(("Cache Bytes : %d", Debug::Memory::GetCacheBytes())) CON_DIAG(("Maximum Memory Usage:")) CON_DIAG(("Allocated Blocks : %d", Debug::Memory::GetMaxAllocatedBlocks())) CON_DIAG(("Allocated Bytes : %d", Debug::Memory::GetMaxAllocatedBytes())) CON_DIAG(("Overhead Bytes : %d", Debug::Memory::GetMaxOverheadBytes())) CON_DIAG(("Cache Blocks : %d", Debug::Memory::GetMaxCacheBlocks())) CON_DIAG(("Cache Bytes : %d", Debug::Memory::GetMaxCacheBytes())) break; } case 0x46B0E840: // "debug.memory.flushcache" Debug::Memory::FlushCache(); break; case 0x238DA5B4: // "debug.memory.validateall" CON_DIAG(("Validating Memory ...")) Debug::Memory::ValidateAll(); break; case 0x1C2EF73F: // "debug.memory.examine" Debug::Memory::Examine(); break; }
U32 Mesh::Manager::Report( MeshRoot & root, Bool all) // = FALSE { U32 mem = root.GetMem(); U32 emem = 0, count = 0; NList<MeshEnt>::Iterator li(&entList); while (MeshEnt * ent = li++) { if (&ent->Root() == &root) { emem += ent->GetMem(); count++; } } remem += emem; recount += count; U32 geo = root.GetMemGeometry(); rgeo += geo; U32 anim = root.GetMemAnim(); ranim += anim; U32 mrm = root.GetMemMRM(); rmrm += mrm; if (all) { CON_DIAG( ("%-36s: f%4ld v%4ld n%4ld u%4ld c%4ld m%3ld a%2ld", root.fileName.str, root.faces.count, root.vertices.count, root.normals.count, root.uvs.count, root.colors.count, root.states.count, root.animCycles.GetCount() )); LOG_DIAG( ("%-36s: f%4ld v%4ld n%4ld u%4ld c%4ld m%3ld a%2ld", root.fileName.str, root.faces.count, root.vertices.count, root.normals.count, root.uvs.count, root.colors.count, root.states.count, root.animCycles.GetCount() )); CON_DIAG( ("%-36s: %9ld g%6ld a%6ld m%6ld c%6ld", " mem total", mem, geo, anim, mrm, root.GetMemChunks() )); LOG_DIAG( ("%-36s: %9ld g%6ld a%6ld m%6ld c%6ld", " mem total", mem, geo, anim, mrm, root.GetMemChunks() )); CON_DIAG( (" %4d %-30s: %9ld", count, "instances", emem)); LOG_DIAG( (" %4d %-30s: %9ld", count, "instances", emem)); } else { CON_DIAG( ("%-36s: %9ld f%4ld v%4ld i%4ld", root.fileName.str, mem + emem, root.faces.count, root.vertices.count, count )); LOG_DIAG( ("%-36s: %9ld f%4ld v%4ld i%4ld", root.fileName.str, mem + emem, root.faces.count, root.vertices.count, count )); } return mem; }
static void Handler(U32 pathCrc) { if (Var::lockout) { return; } char * s1 = NULL; switch (pathCrc) { /* VarSys::CreateInteger("mesh.load.terrmipcount", 4, VarSys::NOTIFY, &Var::terrMipCount); */ case 0xB8DA60B2: // "mesh.anim.blendtime" renderState.animBlendTime = Var::animBlendTime; break; case 0x54135A94: // "mesh.load.mipcount" renderState.mipCount = Var::mipCount; break; case 0xF8D50B70: // "mesh.load.mipmin" renderState.mipMin = Var::mipMin; break; case 0xD4D8592F: // "mesh.load.scale" renderState.scaleFactor = Var::scaleFactor; break; case 0x8D87963B: // "mesh.load.mrmgen" renderState.status.mrmGen = Var::doMrmGen; break; case 0xA3B49A76: // "mesh.show.overlaymip" renderState.status.overlayMip = Var::showOverlayMip; break; case 0xDB6B49D2: // "mesh.show.shadow" renderState.status.showShadows = Var::showShadows; break; case 0x5BD45BD5: // "mesh.show.overlay" renderState.status.overlay = Var::showOverlay; break; case 0x106657EA: // "mesh.show.envmap" renderState.status.envmap = Var::showEnvMap; break; case 0x8D408543: // "mesh.show.hardpoints" renderState.status.showPoints = Var::showHardPoints; break; case 0xF866E28F: // "mesh.show.origin" renderState.status.showOrigin = Var::showOrigin; break; case 0x3067FEC3: // "mesh.show.normals" renderState.status.showNormals = Var::showNormals; break; case 0xE0D39344: // "mesh.show.bounds" renderState.status.showBounds = Var::showBounds; break; case 0x4D511DA8: // "mesh.show.multiweight" renderState.status.multiWeight = Var::doMultiWeight; break; case 0xFA861318: // "mesh.show.interpolation" renderState.status.interpMesh = Var::doInterpolate; break; case 0x26AC80A3: // "mesh.mrm.active" renderState.status.mrm = Var::doMRM; if (!*Var::doMRM) { // restore all meshes to max vertex count Mesh::Manager::FullResList(); } break; case 0xEF4F617A: // "mesh.toggle.mrm" Var::doMRM = !*Var::doMRM; break; case 0x6E2078E8: // "mesh.mrm.auto.active" renderState.status.mrmAuto = Var::mrmAuto; break; case 0x115B9E22: // "mesh.mrm.factor" renderState.mrmFactor1 = Var::mrmFactor; break; case 0x0783E3A9: // "mesh.mrm.distance" renderState.mrmDist = Var::mrmDist; break; /* VarSys::CreateInteger("mesh.mrm.auto.low", low, VarSys::NOTIFY, &Var::mrmLow)->SetIntegerRange(1, 100000); VarSys::CreateInteger("mesh.mrm.auto.high", high, VarSys::NOTIFY, &Var::mrmHigh)->SetIntegerRange(1, 100000); VarSys::CreateFloat("mesh.mrm.auto.constant1", 0.1f, VarSys::NOTIFY, &Var::mrmAutoConstant1); VarSys::CreateFloat("mesh.mrm.auto.constant2", 0.00002f, VarSys::NOTIFY, &Var::mrmAutoConstant2); VarSys::CreateFloat("mesh.mrm.auto.constant3", 0.01f, VarSys::NOTIFY, &Var::mrmAutoConstant3); */ case 0xD1598EAB: // "mesh.toggle.weighting" Var::doMultiWeight = !*Var::doMultiWeight; break; case 0x2768304F: // "mesh.toggle.basepose" Var::doBasePose = !*Var::doBasePose; break; case 0x7081F6C1: // "mesh.toggle.interpolation" Var::doInterpolate = !*Var::doInterpolate; break; case 0x7F22B644: // "mesh.toggle.bounds" Var::showBounds = !*Var::showBounds; break; case 0xDC1078E0: // "mesh.toggle.normals" Var::showNormals = !*Var::showNormals; break; case 0x337EB398: // "mesh.toggle.hardpoints" Var::showHardPoints = !*Var::showHardPoints; break; case 0x792562E7: // "mesh.toggle.origins" Var::showOrigin = !*Var::showOrigin; break; case 0x5790E329: // "mesh.light.quick" renderState.status.lightQuick = Var::lightQuick; Mesh::Manager::SetupRenderProcList(); break; case 0x04149DC1: // "mesh.light.single" renderState.status.lightSingle = Var::lightSingle; break; case 0x18DC25F5: // "mesh.shadow.fadedepth" case 0xE268DB72: // "mesh.shadow.fadedist" renderState.shadowFadeDist = Vid::Math::farPlane * *Var::varShadowFadeDist; renderState.shadowFadeDepthInv = 1 / ((Vid::Math::farPlane - Vid::renderState.shadowFadeDist) * *Var::varShadowFadeDepth); break; case 0x71AFCDF2: // "mesh.shadow.fadecutoff" renderState.shadowFadeCutoff = *Var::varShadowFadeCutoff; break; case 0xF6C26D5A: // "mesh.shadow.y" renderState.shadowY = Var::shadowY; break; case 0xB3474136: // "mesh.shadow.size" renderState.texShadowSize = Var::varShadowSize; break; case 0xAC7D07DF: // "mesh.shadow.nightcolor" { S32 r = 255, g = 255, b = 255, a = 88; Console::GetArgInteger(1, r); Console::GetArgInteger(2, g); Console::GetArgInteger(3, b); Console::GetArgInteger(4, a); nightLightColor.Set( r, g, b, a); break; } case 0xA3E7812D: // "mesh.color.team" renderState.teamColor = *Var::teamColor; if (Mesh::Manager::curEnt) { Mesh::Manager::curParent->SetTeamColor( (Color) *Var::teamColor); } break; case 0x263E1AA9: // "mesh.color.envalpha" renderState.envAlpha = Var::envAlpha; break; case 0x7E8D6042: // "mesh.color.shadowalpha" renderState.shadowAlpha = Var::shadowAlpha; Vid::Light::SetupShadow(); break; // utility // case 0x0C39A9C1: // "mesh.envmap" if (Console::GetArgString( 1, s1)) { Bitmap * map = Bitmap::Manager::Find( s1); if (map) { Mesh::Manager::envMap = map; } } else { CON_DIAG(("envmap = %s", Mesh::Manager::envMap ? Mesh::Manager::envMap->GetName() : "null")); } break; case 0x46BDAA81: // "mesh.color.alpha" case 0x05D592EA: // "mesh.color.base" if (Mesh::Manager::curEnt) { Color color = Var::baseColor; color.a = (U8)Var::alphaColor; Mesh::Manager::curParent->SetBaseColor( color); Mesh::Manager::curParent->SetFogTarget( 255, color.a, TRUE); } break; case 0x7AF1FC7D: // "mesh.diffuse" { F32 f1; if (Console::GetArgFloat(1, f1)) { if (f1 < 0.1f) { f1 = 0.1f; } else if (f1 > 1.0f) { f1 = 1.0f; } Material::Manager::SetDiffuse( f1); } else { CON_DIAG(("diffuse = %.2f", Material::Manager::diffuseVal)) } break; } case 0xD3BE61C1: // "mesh.report" Console::GetArgString(1, s1); Mesh::Manager::ReportList( s1); break; case 0xAA7BD58D: // "mesh.dump.heirarchy" if (Mesh::Manager::curEnt) { Mesh::Manager::curEnt->LogHierarchy(); } break; case 0xEC368032: // "mesh.dump.offsetall" if (Mesh::Manager::curEnt) { Mesh::Manager::curEnt->DumpHierarchy(); } break; case 0x9AC2B5EA: // "mesh.dump.offset" if (Mesh::Manager::curEnt && Console::GetArgString( 1, s1)) { FamilyNode * n1 = Mesh::Manager::curEnt->FindLocal( s1); if (n1 && n1 != Mesh::Manager::curEnt) { FamilyNode * n2 = Mesh::Manager::curEnt; char * s2; if (Console::GetArgString( 2, s2)) { FamilyNode * n = Mesh::Manager::curEnt->FindLocal( s2); if (n) { n2 = n; } } Matrix matrix; matrix.ClearData(); n2->FindOffsetLocal( n1, matrix); CON_DIAG(("")); CON_DIAG(("right %f,%f,%f", matrix.right.x, matrix.right.y, matrix.right.z)); CON_DIAG(("up %f,%f,%f", matrix.up.x, matrix.up.y, matrix.up.z)); CON_DIAG(("front %f,%f,%f", matrix.front.x, matrix.front.y, matrix.front.z)); CON_DIAG(("posit %f,%f,%f", matrix.posit.x, matrix.posit.y, matrix.posit.z)); break; } } CON_DIAG(("app.offset [dstnode] [opt:srcnode]")); break; } }