bool BltObjects::LoadXml() { //cols.clear(); colsMap.clear(); colsMapFind = colsMap.end(); std::string file = PATHMANAGER::GetTreesPath() + "/collisions.xml"; TiXmlDocument doc; if (!doc.LoadFile(file.c_str())) return false; TiXmlElement* root = doc.RootElement(); if (!root) return false; // collisions TiXmlElement *n, *m; const char* a; m = root->FirstChildElement("object"); while (m) { BltCollision col; a = m->Attribute("mesh"); if (a) col.mesh = a; a = m->Attribute("ofs"); if (a) col.offset = s2v(a); // shapes n = m->FirstChildElement("shape"); while (n) { BltShape shp; a = n->Attribute("type"); if (a) { std::string st = a; for (int t=0; t < BLT_ALL; ++t) if (st == sBLTshape[t]) shp.type = (eBLTshape)t; } a = n->Attribute("ofs"); if (a) shp.offset = s2v(a); a = n->Attribute("r"); if (a) shp.radius = s2r(a); a = n->Attribute("h"); if (a) shp.height = s2r(a); a = n->Attribute("frict"); if (a) shp.friction = s2r(a); a = n->Attribute("restit"); if (a) shp.restitution = s2r(a); // add shape col.shapes.push_back(shp); n = n->NextSiblingElement("shape"); } // add collision //cols.push_back(col); colsMap[col.mesh] = col; // map m = m->NextSiblingElement("object"); } return true; }
UpVal *luaF_findupval (lua_State *L, StkId level) { UpVal **pp = &L->openupval; GCObject *o; UpVal *p; UpVal *uv; lua_assert(isintwups(L) || L->openupval == NULL); while ((p = *pp) != NULL && uplevel(p) >= level) { if (uplevel(p) == level && !isdead(G(L), p)) /* corresponding upvalue? */ return p; /* return it */ pp = &p->u.open.next; } /* not found: create a new upvalue between 'pp' and 'p' */ o = luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal)); uv = gco2upv(o); uv->u.open.next = p; /* link it to list of open upvalues */ uv->u.open.previous = pp; if (p) p->u.open.previous = &uv->u.open.next; *pp = uv; uv->v = s2v(level); /* current value lives in the stack */ if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ L->twups = G(L)->twups; /* link it to the list */ G(L)->twups = L; } return uv; }
void vtLodGrid::RemoveFromGrid(osg::Node *pNode) { osg::Group *pGroup = FindCellParent(s2v(pNode->getBound().center())); if (pGroup && pGroup->getChildIndex(pNode) != pGroup->getNumChildren()) pGroup->removeChild(pNode); else { /* * Search through all of the LOD grid's cells looking * for the node, so we can handle even cases where the object may have * moved out of its original cell. */ int a, b; for (a = 0; a < m_dim; a++) { for (b = 0; b < m_dim; b++) { osg::Group *group = GetCell(a, b); if (group && group->getChildIndex(pNode) != group->getNumChildren()) { group->removeChild(pNode); return; } } } } }
int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, TMS event) { if (callbinTM(L, p1, p2, L->top, event)) /* try original event */ return !l_isfalse(s2v(L->top)); #if defined(LUA_COMPAT_LT_LE) else if (event == TM_LE) { /* try '!(p2 < p1)' for '(p1 <= p2)' */ L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ if (callbinTM(L, p2, p1, L->top, TM_LT)) { L->ci->callstatus ^= CIST_LEQ; /* clear mark */ return l_isfalse(s2v(L->top)); } /* else error will remove this 'ci'; no need to clear mark */ } #endif luaG_ordererror(L, p1, p2); /* no metamethod found */ return 0; /* to avoid warnings */ }
int luaH_next (lua_State *L, Table *t, StkId key) { unsigned int asize = luaH_realasize(t); unsigned int i = findindex(L, t, s2v(key), asize); /* find original key */ for (; i < asize; i++) { /* try first array part */ if (!isempty(&t->array[i])) { /* a non-empty entry? */ setivalue(s2v(key), i + 1); setobj2s(L, key + 1, &t->array[i]); return 1; } } for (i -= asize; cast_int(i) < sizenode(t); i++) { /* hash part */ if (!isempty(gval(gnode(t, i)))) { /* a non-empty entry? */ Node *n = gnode(t, i); getnodekey(L, s2v(key), n); setobj2s(L, key + 1, gval(n)); return 1; } } return 0; /* no more elements */ }
void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) { int i; int nextra = ci->u.l.nextraargs; if (wanted < 0) { wanted = nextra; /* get all extra arguments available */ checkstackp(L, nextra, where); /* ensure stack space */ L->top = where + nextra; /* next instruction will need top */ } for (i = 0; i < wanted && i < nextra; i++) setobjs2s(L, where + i, ci->func - nextra + i); for (; i < wanted; i++) /* complete required results with nil */ setnilvalue(s2v(where + i)); }
bool vtLodGrid::AddToGrid(osg::Node *pNode) { osg::BoundingSphere sph = pNode->getBound(); osg::Group *pGroup = FindCellParent(s2v(sph.center())); if (pGroup) { pGroup->addChild(pNode); return true; } else return false; }
void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci, const Proto *p) { int i; int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */ int nextra = actual - nfixparams; /* number of extra arguments */ ci->u.l.nextraargs = nextra; checkstackGC(L, p->maxstacksize + 1); /* copy function to the top of the stack */ setobjs2s(L, L->top++, ci->func); /* move fixed parameters to the top of the stack */ for (i = 1; i <= nfixparams; i++) { setobjs2s(L, L->top++, ci->func + i); setnilvalue(s2v(ci->func + i)); /* erase original parameter (for GC) */ } ci->func += actual + 1; ci->top += actual + 1; lua_assert(L->top <= ci->top && ci->top <= L->stack_last); }