// Builds a uniformly subdivided tree for the given world size static areanode_t *SV_CreateAreaNode(int depth, const CBox &bounds) { areanode_t &anode = areaNodes[numAreaNodes++]; ClearLink(anode.trigEdicts); ClearLink(anode.solidEdicts); if (depth == AREA_DEPTH) { anode.axis = -1; anode.children[0] = anode.children[1] = NULL; return &anode; } float f0 = bounds.maxs[0] - bounds.mins[0]; float f1 = bounds.maxs[1] - bounds.mins[1]; float f2 = bounds.maxs[2] - bounds.mins[2]; if (f0 > f1) anode.axis = f0 > f2 ? 0 : 2; else anode.axis = f1 > f2 ? 1 : 2; // split bounds into 2 identical by volume sub-bounds anode.dist = (bounds.maxs[anode.axis] + bounds.mins[anode.axis]) / 2; CBox bounds1 = bounds; CBox bounds2 = bounds; bounds1.maxs[anode.axis] = bounds2.mins[anode.axis] = anode.dist; anode.children[0] = SV_CreateAreaNode(depth+1, bounds1); anode.children[1] = SV_CreateAreaNode(depth+1, bounds2); anode.children[0]->parent = anode.children[1]->parent = &anode; // NULL for root, because of memset(..,0,..) return &anode; }
/* * =============== * SV_CreateAreaNode * * Builds a uniformly subdivided tree for the given world size * =============== */ areanode_t *SV_CreateAreaNode(int depth, vec3_t mins, vec3_t maxs) { areanode_t *anode; vec3_t size; vec3_t mins1, maxs1, mins2, maxs2; anode = &sv_areanodes[sv_numareanodes]; sv_numareanodes++; ClearLink(&anode->trigger_edicts); ClearLink(&anode->solid_edicts); if (depth == AREA_DEPTH) { anode->axis = -1; anode->children[0] = anode->children[1] = NULL; return anode; } VectorSubtract(maxs, mins, size); if (size[0] > size[1]) { anode->axis = 0; } else { anode->axis = 1; } anode->dist = 0.5 * (maxs[anode->axis] + mins[anode->axis]); VectorCopy(mins, mins1); VectorCopy(mins, mins2); VectorCopy(maxs, maxs1); VectorCopy(maxs, maxs2); maxs1[anode->axis] = mins2[anode->axis] = anode->dist; anode->children[0] = SV_CreateAreaNode(depth + 1, mins2, maxs2); anode->children[1] = SV_CreateAreaNode(depth + 1, mins1, maxs1); return anode; }
CLIENTFX_INSTANCE::~CLIENTFX_INSTANCE() { ClearLink(); //make sure to free all of our effects RemoveAllEffects(); if (m_hAlternateParent) { CClientFXMgr::GetClientDE()->RemoveObject(m_hAlternateParent); } }