Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "base.h"
- #include "portalvolume.h"
- PortalVolume::PortalVolume(Entity* pEntity) : Puppeteer(pEntity)
- {
- DevMsg("PortalVolume!!!!");
- MakeEntInvisible(pEntity);
- Start();
- }
- void PortalVolume::Start()
- {
- SearchForEntites();
- }
- bool IsEntityInside(Entity* ent)
- {
- AABB* aabb = ent->GetAABB(Entity::GlobalAABB);
- Vec3 pos = entity->GetPosition(true);
- if (pos.x < aabb->min.x) { return false; }
- if (pos.y < aabb->min.y) { return false; }
- if (pos.z < aabb->min.z) { return false; }
- if (pos.x > aabb->max.x) { return false; }
- if (pos.y > aabb->max.y) { return false; }
- if (pos.z > aabb->max.z) { return false; }
- return true;
- }
- void Callback(Entity* entity, Object* extra)
- {
- if (entity->GetClass() == Object::ModelClass)
- {
- // Skip collapsed brushes, no real need to cull them.
- Model* mdl = static_cast<Model*>(entity);
- if (mdl->collapsedfrombrushes)
- return;
- }
- // This is us!
- PortalVolume* volume = static_cast<PortalVolume*>(extra);
- if (entity == volume->entity)
- return;
- if (!IsEntityInside(ent))
- return;
- volume->m_hEntsInVolume.push_back(entity);
- DevMsg(volume->entity->GetKeyValue("name"));
- DevMsg("Pushed Back Entity: " + entity->GetKeyValue("name"));
- }
- void PortalVolume::SearchForEntites()
- {
- WORLD->ForEachEntityInAABBDo(entity->GetAABB(Entity::GlobalAABB), Callback, this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement