本文整理汇总了C++中SPBItem::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ SPBItem::Update方法的具体用法?C++ SPBItem::Update怎么用?C++ SPBItem::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPBItem
的用法示例。
在下文中一共展示了SPBItem::Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildNodes
void ESceneAIMapTool::BuildNodes(bool bFromSelectedOnly)
{
// begin
m_Nodes.reserve (1024*1024);
// Initialize hash
// hash_Initialize ();
R_ASSERT(!m_Nodes.empty());
// Estimate nodes
Fvector Pos,LevelSize;
m_AIBBox.getsize (LevelSize);
float estimated_nodes = (LevelSize.x/m_Params.fPatchSize)*(LevelSize.z/m_Params.fPatchSize);
SPBItem* pb = UI->ProgressStart(1, "Building nodes...");
// General cycle
for (int k=0; k<(int)m_Nodes.size(); k++){
SAINode* N = m_Nodes[k];
if (bFromSelectedOnly && !N->flags.is(SAINode::flSelected)) continue;
// left
if (0==N->n1){
Pos.set (N->Pos);
Pos.x -= m_Params.fPatchSize;
N->n1 = BuildNode(N->Pos,Pos,false);
}
// fwd
if (0==N->n2){
Pos.set (N->Pos);
Pos.z += m_Params.fPatchSize;
N->n2 = BuildNode(N->Pos,Pos,false);
}
// right
if (0==N->n3){
Pos.set (N->Pos);
Pos.x += m_Params.fPatchSize;
N->n3 = BuildNode(N->Pos,Pos,false);
}
// back
if (0==N->n4){
Pos.set (N->Pos);
Pos.z -= m_Params.fPatchSize;
N->n4 = BuildNode(N->Pos,Pos,false);
}
if (bFromSelectedOnly){
// select neighbour nodes
if (N->n1) N->n1->flags.set(SAINode::flSelected,TRUE);
if (N->n2) N->n2->flags.set(SAINode::flSelected,TRUE);
if (N->n3) N->n3->flags.set(SAINode::flSelected,TRUE);
if (N->n4) N->n4->flags.set(SAINode::flSelected,TRUE);
}
if (k%512==0) {
float p1 = float(k)/float(m_Nodes.size());
float p2 = float(m_Nodes.size())/estimated_nodes;
float p = 0.1f*p1+0.9f*p2;
clamp (p,0.f,1.f);
pb->Update(p);
// check need abort && redraw
if (k%32768==0) UI->RedrawScene(true);
if (UI->NeedAbort()) break;
}
}
UI->ProgressEnd(pb);
}
示例2: SmoothNodes
//.........这里部分代码省略.........
if (R.nBack()) {
bCorner = true;
SAINode& C = *R.nBack();
C.PointLF(P,m_Params.fPatchSize); merge(P3);
}
}
if (N.nBack()) {
SAINode& B = *N.nBack();
B.PointFR(P,m_Params.fPatchSize); merge(P3);
if ((!bCorner) && B.nRight()) {
bCorner = true;
SAINode& C = *B.nRight();
C.PointLF(P,m_Params.fPatchSize); merge(P3);
}
}
R_ASSERT(c<=4);
P3.div(float(c));
}
// smooth point BL
{
bool bCorner = false;
c=1; N.PointBL(REF,m_Params.fPatchSize); P4.set(REF);
if (N.nBack()) {
SAINode& B = *N.nBack();
B.PointLF(P,m_Params.fPatchSize); merge(P4);
if (B.nLeft()) {
bCorner = true;
SAINode& C = *B.nLeft();
C.PointFR(P,m_Params.fPatchSize); merge(P4);
}
}
if (N.nLeft()) {
SAINode& L = *N.nLeft();
L.PointRB(P,m_Params.fPatchSize); merge(P4);
if ((!bCorner) && L.nBack()) {
bCorner = true;
SAINode& C = *L.nBack();
C.PointFR(P,m_Params.fPatchSize); merge(P4);
}
}
R_ASSERT(c<=4);
P4.div(float(c));
}
// align plane
Fvector data[4]; data[0]=P1; data[1]=P2; data[2]=P3; data[3]=P4;
Fvector vOffs,vNorm,D;
vNorm.set(N.Plane.n);
vOffs.set(N.Pos);
Mgc::OrthogonalPlaneFit(
4,(Mgc::Vector3*)data,
*((Mgc::Vector3*)&vOffs),
*((Mgc::Vector3*)&vNorm)
);
if (vNorm.y<0) vNorm.invert();
// create _new node
SAINode* NEW = xr_new<SAINode>(N);
NEW->n1 = (SAINode*)(N.n1?N.n1->idx:InvalidNode);
NEW->n2 = (SAINode*)(N.n2?N.n2->idx:InvalidNode);
NEW->n3 = (SAINode*)(N.n3?N.n3->idx:InvalidNode);
NEW->n4 = (SAINode*)(N.n4?N.n4->idx:InvalidNode);
NEW->Plane.build(vOffs,vNorm);
D.set (0,1,0);
N.Plane.intersectRayPoint(N.Pos,D,NEW->Pos); // "project" position
smoothed.push_back (NEW);
}else{
// create _new node
SAINode* NEW = xr_new<SAINode>(N);
NEW->n1 = (SAINode*)(N.n1?N.n1->idx:InvalidNode);
NEW->n2 = (SAINode*)(N.n2?N.n2->idx:InvalidNode);
NEW->n3 = (SAINode*)(N.n3?N.n3->idx:InvalidNode);
NEW->n4 = (SAINode*)(N.n4?N.n4->idx:InvalidNode);
smoothed.push_back (NEW);
}
int k = it-m_Nodes.begin();
if (k%128==0) {
pb->Update(k);
if (UI->NeedAbort()) break;
}
}
UI->ProgressEnd(pb);
Clear (true);
m_Nodes = smoothed;
DenumerateNodes ();
hash_FillFromNodes ();
UpdateHLSelected ();
if (sm_nodes) Scene->UndoSave();
}