virtual void OnIterStart(SActivationInfo *pActInfo) { const int type = GetPortInt(pActInfo, EIP_Type); IEntitySystem *pEntitySystem = gEnv->pEntitySystem; if (pEntitySystem) { IEntityItPtr iter = pEntitySystem->GetEntityIterator(); if (iter) { iter->MoveFirst(); IEntity *pEntity = NULL; while (!iter->IsEnd()) { pEntity = iter->Next(); if (pEntity) { const EntityId id = pEntity->GetId(); const EEntityType entityType = GetEntityType(id); if (IsValidType(type, entityType)) { AddEntity(id); } } } } } }
FCDEntityInstance* FCDPhysicsForceFieldInstance::Clone( FCDEntityInstance* _clone) const { FCDPhysicsForceFieldInstance* clone = NULL; if (_clone == NULL) clone = new FCDPhysicsForceFieldInstance( const_cast<FCDocument*>(GetDocument()), const_cast<FCDSceneNode*>(GetParent()), GetEntityType()); else if (!_clone->HasType(FCDPhysicsForceFieldInstance::GetClassType())) return Parent::Clone(_clone); else clone = (FCDPhysicsForceFieldInstance*) _clone; Parent::Clone(clone); // nothing interesting in force field instance to copy return clone; }
virtual void OnIterStart(SActivationInfo *pActInfo) { const int type = GetPortInt(pActInfo, EIP_Type); const Vec3& min(GetPortVec3(pActInfo, EIP_Min)); const Vec3& max(GetPortVec3(pActInfo, EIP_Max)); IPhysicalWorld *pWorld = gEnv->pPhysicalWorld; IPhysicalEntity **ppList = NULL; int numEnts = pWorld->GetEntitiesInBox(min,max,ppList,ent_all); for (int i = 0; i < numEnts; ++i) { const EntityId id = pWorld->GetPhysicalEntityId(ppList[i]); const EEntityType entityType = GetEntityType(id); if (IsValidType(type, entityType)) { AddEntity(id); } } }
virtual void OnIterStart(SActivationInfo *pActInfo) { const int type = GetPortInt(pActInfo, EIP_Type); const Vec3& center(GetPortVec3(pActInfo, EIP_Pos)); const float range = GetPortFloat(pActInfo, EIP_Range); const float rangeSq = range * range; const Vec3 min(center.x-range, center.y-range, center.z-range); const Vec3 max(center.x+range, center.y+range, center.z+range); IPhysicalWorld *pWorld = gEnv->pPhysicalWorld; IPhysicalEntity **ppList = NULL; int numEnts = pWorld->GetEntitiesInBox(min,max,ppList,ent_all); for (int i = 0; i < numEnts; ++i) { const EntityId id = pWorld->GetPhysicalEntityId(ppList[i]); const EEntityType entityType = GetEntityType(id); if (IsValidType(type, entityType)) { AddEntity(id); } } }
virtual void OnIterStart(SActivationInfo *pActInfo) { const int type = GetPortInt(pActInfo, EIP_Type); const char* area = GetPortString(pActInfo, EIP_Area); // Find the entity IEntitySystem *pEntitySystem = gEnv->pEntitySystem; if (pEntitySystem) { IEntity *pArea = pEntitySystem->FindEntityByName(area); if (pArea) { IEntityAreaProxy *pAreaProxy = (IEntityAreaProxy*)pArea->GetProxy(ENTITY_PROXY_AREA); if (pAreaProxy) { Vec3 min, max, worldPos(pArea->GetWorldPos()); min.Set(0.f,0.f,0.f); max.Set(0.f,0.f,0.f); EEntityAreaType areaType = pAreaProxy->GetAreaType(); // Construct bounding space around area switch (areaType) { case ENTITY_AREA_TYPE_BOX: { pAreaProxy->GetBox(min, max); min += worldPos; max += worldPos; } break; case ENTITY_AREA_TYPE_SPHERE: { Vec3 center; float radius = 0.f; pAreaProxy->GetSphere(center, radius); min.Set(center.x-radius, center.y-radius, center.z-radius); max.Set(center.x+radius, center.y+radius, center.z+radius); } break; case ENTITY_AREA_TYPE_SHAPE: { const Vec3 *points = pAreaProxy->GetPoints(); const int count = pAreaProxy->GetPointsCount(); if (count > 0) { Vec3 p = worldPos + points[0]; min = p; max = p; for (int i = 1; i < count; ++i) { p = worldPos + points[i]; if (p.x < min.x) min.x = p.x; if (p.y < min.y) min.y = p.y; if (p.z < min.z) min.z = p.z; if (p.x > max.x) max.x = p.x; if (p.y > max.y) max.y = p.y; if (p.z > max.z) max.z = p.z; } } } break; } IPhysicalWorld *pWorld = gEnv->pPhysicalWorld; IPhysicalEntity **ppList = NULL; int numEnts = pWorld->GetEntitiesInBox(min,max,ppList,ent_all); for (int i = 0; i < numEnts; ++i) { const EntityId id = pWorld->GetPhysicalEntityId(ppList[i]); const EEntityType entityType = GetEntityType(id); if (IsValidType(type, entityType)) { // Sanity check - Test entity's position IEntity *pEntity = pEntitySystem->GetEntity(id); if (pEntity && pAreaProxy->CalcPointWithin(id, pEntity->GetWorldPos(), pAreaProxy->GetHeight()==0)) { AddEntity(id); } } } } } } }
FCDEntityInstance* FCDGeometryInstance::Clone(FCDEntityInstance* _clone) const { FCDGeometryInstance* clone = NULL; if (_clone == NULL) clone = new FCDGeometryInstance(const_cast<FCDocument*>(GetDocument()), const_cast<FCDSceneNode*>(GetParent()), GetEntityType()); else if (!_clone->HasType(FCDGeometryInstance::GetClassType())) return Parent::Clone(_clone); else clone = (FCDGeometryInstance*) _clone; Parent::Clone(clone); size_t parameterCount = parameters.size(); for (size_t p = 0; p < parameterCount; ++p) { FCDEffectParameter* clonedParameter = clone->AddEffectParameter(parameters[p]->GetType()); parameters[p]->Clone(clonedParameter); } // Clone the material instances. for (const FCDMaterialInstance** it = materials.begin(); it != materials.end(); ++it) { FCDMaterialInstance* materialInstance = clone->AddMaterialInstance(); (*it)->Clone(materialInstance); } return clone; }