void IFXCharacter::GenerateBoneLinks(I32 defaultnumber) { ForEachNode(IFXCHILDFIRST,&IFXCharacter::CreateLinksOnNode,&defaultnumber); GetSkin()->RelinkWeights(); GetSkin()->FilterWeights(); RecalcLinks(); ForEachNodeTransformed(IFXPARENTFIRST|IFXSTORE_XFORM,NULL); ForEachNode(IFXCHILDFIRST,&IFXCharacter::CalcLinkReferencesOnNode); GetSkin()->ComputeVertexOffsets(); }
/****************************************************************************** non-link bones ******************************************************************************/ I32 IFXCharacter::CountRealBones(void) { I32 bones=0; ForEachNode(IFXCHILDFIRST,&IFXCharacter::CountRealBone,&bones); return bones; }
void IFXCharacter::BlendBones(F32 weight) { F32 weight2=weight; if(weight2<0.0f) weight2=0.0f; if(weight2>1.0f) weight2=1.0f; ForEachNode(IFXCHILDFIRST,&IFXCharacter::BlendBoneNode,&weight2); }
void TreeOptimizer::step2() {//make select and product into a join NodePairs pairs; NodeCallBack cb = boost::BOOST_BIND(GetMergeNodes, _1, _2, _3, boost::ref(pairs)); ForEachNode(root, cb); BOOST_FOREACH(NodePairs::value_type val , pairs) { val.first->setType(JOIN); val.first->children = val.second->children; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Print(CallGraph* callGraph, Unit* unit) { // Print the external and unknown nodes. NewNode(ExternalCallNode::GetExternalNode(), "EXTERNAL", COLOR_LIGHT_PINK, SHAPE_RECT); NewNode(UnknownCallNode::GetUnknownNode(), "UNKNOWN", COLOR_LIGHT_GREEN, SHAPE_RECT); // Print the nodes for each function, then create the links. for(auto funct = unit->Functions().First(); funct; funct = funct->Next) { auto functionRef = GetFunctionReference(funct->Value, unit); auto node = callGraph->GetNode(functionRef); NewNode(node, *funct->Value->Name(), COLOR_LIGHT_BLUE, SHAPE_TRAPEZIUM); node->ForEachCallSite([this](CallSite* site) -> bool { string name = string::Format(L"%d", site->GetCallId()); NewNode(site, name, COLOR_LIGHT_GREY, SHAPE_ELLIPSE); return true; }); } auto& nodeGroups = callGraph->GetCallNodeGroups(); for(int i = 0; i < nodeGroups.Count(); i++) { auto nodeGroup = nodeGroups[i]; string name = string::Format(L"Group: %d", nodeGroup->NodeCount()); NewNode(nodeGroup, name, COLOR_YELLOW, SHAPE_DIAMOND); nodeGroup->ForEachNode([this, nodeGroup](CallNodeBase* node) -> bool { Link(nodeGroup, node); return true; }); } for(auto funct = unit->Functions().First(); funct; funct = funct->Next) { auto functionRef = GetFunctionReference(funct->Value, unit); auto node = callGraph->GetNode(functionRef); CreateLinks(node); } CreateLinks(ExternalCallNode::GetExternalNode()); CreateLinks(UnknownCallNode::GetUnknownNode()); Close(); }
void Profiler::ForEachNode(Phase tag, TypeNode *node, FVisit visit, Phase parentTag) { AssertMsg(node != NULL, "Invalid usage: node must always be non null"); for(int i = 0; i < PhaseCount; i++) { if(node->ChildExistsAt(i)) { TypeNode * child = node->GetChildAt(i); if(i == tag) { visit(child, parentTag); } else { ForEachNode(tag, child, visit, static_cast<Phase>(i)); } } } }
void TreeOptimizer::step1() {//fill in select exp NodeCallBack cb = boost::BOOST_BIND(FillInSelect, _1, _2, _3); ForEachNode(root, cb); }
void Profiler::Print(Phase baseTag) { if (baseTag == InvalidPhase) { baseTag = AllPhase; // default to all phase } const TimeStamp freq = this->GetFrequency(); bool foundNode = false; ForEachNode(baseTag, &rootNode, [&](TypeNode *const baseNode, const Phase parentTag) { if(!foundNode) { foundNode = true; Output::Print(L"%-*s:%7s %5s %7s %5s %7s %7s %5s\n", (Profiler::PhaseNameWidth-0), L"Profiler Report", L"Incl", L"(%)", L"Excl", L"(%)", L"Max", L"Mean", L"Count" ); Output::Print(L"-------------------------------------------------------------------------------\n"); } UnitData *data = baseNode->GetValue(); if(0 == data->count) { Output::Print(L"The phase : %s was never started", PhaseNames[baseTag]); return; } int indent = 0; if(parentTag != InvalidPhase) { TypeNode *const parentNode = baseNode->GetParent(); Assert(parentNode); Output::Print(L"%-*s\n", (Profiler::PhaseNameWidth-0), PhaseNames[parentTag]); indent += Profiler::TabWidth; } if(indent) { Output::SkipToColumn(indent); } Output::Print(L"%-*s %7.1f %5d %7.1f %5d %7.1f %7.1f %5d\n", (Profiler::PhaseNameWidth-indent), PhaseNames[baseTag], (double)data->incl / freq , // incl int(100), // incl % (double)data->excl / freq , // excl int(data->excl * 100 / data->incl ), // excl % (double)data->max / freq , // max (double)data->incl / ( freq * data->count ),// mean int(data->count) // count ); indent += Profiler::TabWidth; PrintTree(baseNode, baseNode, indent, freq); }); if(foundNode) { Output::Print(L"-------------------------------------------------------------------------------\n"); Output::Flush(); } }
void IFXCharacter::RecalcLinks(void) { ForEachNode(IFXPARENTFIRST,&IFXCharacter::RecalcLinksOnNode); }
void IFXCharacter::RebuildBoneTable(void) { ClearBoneTable(); ForEachNode(IFXCHILDFIRST,&IFXCharacter::AddBoneToTable,this); }
void IFXCharacter::RemoveBoneLinks(void) { ForEachNode(IFXCHILDFIRST,&IFXCharacter::RemoveBoneLinkNode,0); RebuildBoneTable(); }
void IFXCharacter::ResetToFullReach(void) { ForEachNode(IFXPARENTFIRST,&IFXCharacter::ResetToFullReachOnNode); }
void IFXCharacter::ResetToReference(void) { ForEachNode(IFXPARENTFIRST,&IFXCharacter::ResetToReferenceOnNode); }