Aggregate.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. namespace EE{
  4. /******************************************************************************/
  5. void Aggregate::del()
  6. {
  7. #if PHYSX
  8. if(_aggr)
  9. {
  10. SafeWriteLock lock(Physics._rws);
  11. if(_aggr)
  12. {
  13. if(Physx.physics)_aggr->release();
  14. _aggr=null;
  15. }
  16. }
  17. #endif
  18. }
  19. void Aggregate::create(Int max_actors, Bool self_collision)
  20. {
  21. del();
  22. #if PHYSX
  23. WriteLock lock(Physics._rws);
  24. if(Physx.physics)
  25. if(_aggr=Physx.physics->createAggregate(max_actors, self_collision))Physx.world->addAggregate(*_aggr);
  26. #endif
  27. }
  28. void Aggregate::add(Actor &actor)
  29. {
  30. #if PHYSX
  31. if(_aggr && actor._actor)
  32. {
  33. WriteLock lock(Physics._rws);
  34. if(_aggr && actor._actor && Physx.world)
  35. {
  36. Physx.world->removeActor(*actor._actor); // actor needs to be first removed from the scene
  37. _aggr->addActor(*actor._actor); // now add to aggregate
  38. }
  39. }
  40. #endif
  41. }
  42. /******************************************************************************/
  43. }
  44. /******************************************************************************/