Advertisement
Codeblocks

Untitled

Aug 2nd, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include "base.h"
  2. #include "portalvolume.h"
  3.  
  4. PortalVolume::PortalVolume(Entity* pEntity) : Puppeteer(pEntity)
  5. {
  6.     DevMsg("PortalVolume!!!!");
  7.     MakeEntInvisible(pEntity);
  8.     Start();
  9. }
  10.  
  11. void PortalVolume::Start()
  12. {
  13.     SearchForEntites();
  14. }
  15.  
  16. bool IsEntityInside(Entity* ent)
  17. {
  18.     AABB* aabb = ent->GetAABB(Entity::GlobalAABB);
  19.     Vec3 pos = entity->GetPosition(true);
  20.     if (pos.x < aabb->min.x) { return false; }
  21.     if (pos.y < aabb->min.y) { return false; }
  22.     if (pos.z < aabb->min.z) { return false; }
  23.     if (pos.x > aabb->max.x) { return false; }
  24.     if (pos.y > aabb->max.y) { return false; }
  25.     if (pos.z > aabb->max.z) { return false; }
  26.     return true;
  27. }
  28.  
  29. void Callback(Entity* entity, Object* extra)
  30. {
  31.    
  32.     if (entity->GetClass() == Object::ModelClass)
  33.     {
  34.         // Skip collapsed brushes, no real need to cull them.
  35.         Model* mdl = static_cast<Model*>(entity);
  36.         if (mdl->collapsedfrombrushes)
  37.             return;
  38.     }
  39.  
  40.     // This is us!
  41.     PortalVolume* volume = static_cast<PortalVolume*>(extra);
  42.     if (entity == volume->entity)
  43.         return;
  44.  
  45.     if (!IsEntityInside(ent))
  46.         return;
  47.  
  48.     volume->m_hEntsInVolume.push_back(entity);
  49.     DevMsg(volume->entity->GetKeyValue("name"));
  50.     DevMsg("Pushed Back Entity: " + entity->GetKeyValue("name"));
  51. }
  52.  
  53.  
  54.  
  55. void PortalVolume::SearchForEntites()
  56. {
  57.     WORLD->ForEachEntityInAABBDo(entity->GetAABB(Entity::GlobalAABB), Callback, this);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement