Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OPC_SweepAndPrune.cpp File Reference
#include "Stdafx.h"

Go to the source code of this file.

Classes

class  Opcode::SAP_Element
 
class  Opcode::SAP_Box
 
class  Opcode::SAP_EndPoint
 

Functions

inline_ void Sort (udword &id0, udword &id1)
 
inline_ void Remap (SAP_Element *&element, udword delta)
 
inline_ bool Intersect (const AABB &a, const SAP_Box &b)
 

Detailed Description

Contains an implementation of the sweep-and-prune algorithm (moved from Z-Collide)

Author
Pierre Terdiman
Date
January, 29, 2000

Definition in file OPC_SweepAndPrune.cpp.

Function Documentation

inline_ bool Intersect ( const AABB a,
const SAP_Box b 
)

Definition at line 525 of file OPC_SweepAndPrune.cpp.

References FALSE, Opcode::AABB::GetMax(), Opcode::AABB::GetMin(), Opcode::SAP_Box::Max, Opcode::SAP_Box::Min, TRUE, and Opcode::SAP_EndPoint::Value.

Referenced by Opcode::SweepAndPrune::Init(), and Opcode::SweepAndPrune::UpdateObject().

526 {
527  if(b.Max[0]->Value < a.GetMin(0) || a.GetMax(0) < b.Min[0]->Value
528  || b.Max[1]->Value < a.GetMin(1) || a.GetMax(1) < b.Min[1]->Value
529  || b.Max[2]->Value < a.GetMin(2) || a.GetMax(2) < b.Min[2]->Value) return FALSE;
530 
531  return TRUE;
532 }
inline_ void Remap ( SAP_Element *&  element,
udword  delta 
)

Remaps a pointer when pool gets resized.

Parameters
element[in/out] remapped element
delta[in] offset in bytes

Definition at line 166 of file OPC_SweepAndPrune.cpp.

Referenced by Opcode::SAP_PairData::AddPair().

167 {
168  if(element) element = (SAP_Element*)(uintptr_t(element) + delta);
169 }
inline_ void Sort ( udword id0,
udword id1 
)

Definition at line 25 of file OPC_SweepAndPrune.cpp.

References Swap().

Referenced by Opcode::SAP_PairData::AddPair(), and Opcode::SAP_PairData::RemovePair().

26 {
27  if(id0>id1) Swap(id0, id1);
28 }