void Brush::setEntity(Entity* entity) { if (entity == m_entity) return; if (m_entity != NULL) { if (selected()) m_entity->decSelectedBrushCount(); else if (hidden()) m_entity->decHiddenBrushCount(); if (entity == NULL && m_geometry != NULL) { delete m_geometry; m_geometry = NULL; } } else if (entity != NULL && m_geometry == NULL) { rebuildGeometry(); } m_entity = entity; if (m_entity != NULL) { if (selected()) m_entity->incSelectedBrushCount(); else if (hidden()) m_entity->incHiddenBrushCount(); } }
void Brush::moveBoundary(Face& face, const Vec3f& delta, bool lockTexture) { assert(canMoveBoundary(face, delta)); const Mat4f pointTransform = translationMatrix(delta); face.transform(pointTransform, Mat4f::Identity, false, false); rebuildGeometry(); }
void Brush::transform(const Mat4f& pointTransform, const Mat4f& vectorTransform, const bool lockTextures, const bool invertOrientation) { FaceList::const_iterator faceIt, faceEnd; for (faceIt = m_faces.begin(), faceEnd = m_faces.end(); faceIt != faceEnd; ++faceIt) { Face& face = **faceIt; face.transform(pointTransform, vectorTransform, lockTextures, invertOrientation); } rebuildGeometry(); }
bool Brush::clip(Face& face) { try { face.setBrush(this); m_faces.push_back(&face); rebuildGeometry(); return !m_faces.empty() && closed(); } catch (GeometryException&) { return false; } }
void Brush::setForceIntegerFacePoints(bool forceIntegerFacePoints) { FaceList::const_iterator faceIt, faceEnd; for (faceIt = m_faces.begin(), faceEnd = m_faces.end(); faceIt != faceEnd; ++faceIt) { Face& face = **faceIt; face.setForceIntegerFacePoints(forceIntegerFacePoints); } m_forceIntegerFacePoints = forceIntegerFacePoints; rebuildGeometry(); }
void Brush::restore(const FaceList& faces) { Utility::deleteAll(m_faces); FaceList::const_iterator it, end; for (it = faces.begin(), end = faces.end(); it != end; ++it) { Face* face = *it; face->setBrush(this); m_faces.push_back(face); } rebuildGeometry(); }
void Brush::restore(const Brush& brushTemplate, bool checkId) { if (checkId) assert(uniqueId() == brushTemplate.uniqueId()); Utility::deleteAll(m_faces); const FaceList templateFaces = brushTemplate.faces(); for (size_t i = 0; i < templateFaces.size(); i++) { Face* face = new Face(m_worldBounds, m_forceIntegerFacePoints, *templateFaces[i]); face->setBrush(this); m_faces.push_back(face); } rebuildGeometry(); }
Brush::Brush(const BBoxf& worldBounds, bool forceIntegerFacePoints, const FaceList& faces) : MapObject(), m_geometry(NULL), m_worldBounds(worldBounds), m_forceIntegerFacePoints(forceIntegerFacePoints) { init(); FaceList::const_iterator it, end; for (it = faces.begin(), end = faces.end(); it != end; ++it) { Face* face = *it; face->setBrush(this); m_faces.push_back(face); } rebuildGeometry(); }
void DeferredLight::setAttenuation(Ogre::Real c, Ogre::Real b, Ogre::Real a) { Ogre::Real outerRadius = parentLight->getAttenuationRange(); if (c != 1.0 || b != 0.0 || a != 0.0) { ENABLE_BIT(permutation, LightMaterialGenerator::MI_ATTENUATED); if (parentLight->getType() == Ogre::Light::LT_POINT) { int thresholdLevel = 10; Ogre::Real threshold = 1.0 / ((Ogre::Real)thresholdLevel / 256.0); c -= threshold; Ogre::Real d = Ogre::Math::Sqrt(b * b - 4 * a * c); outerRadius = (-2 * c) / (b + d); outerRadius *= 1.2; } } else { DISABLE_BIT(permutation, LightMaterialGenerator::MI_ATTENUATED); } rebuildGeometry(outerRadius); }
void DeferredLight::setAttenuation(float c, float b, float a) { float outerRadius = mParentLight->getAttenuationRange(); if (c != 1.0f || b != 0.0f || a != 0.0f) { ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_ATTENUATED); if (mParentLight->getType() == Ogre::Light::LT_POINT) { float minAttenuation = 1.0f / (MINIMUM_ATTENUATION / 256.0f); c -= minAttenuation; outerRadius = (-2 * c) / (b + sqrt(b * b - 4 * a * c)); } } else { DISABLE_BIT(mPermutation,LightMaterialGenerator::MI_ATTENUATED); } rebuildGeometry(outerRadius); }
void Brush::snap(unsigned int snapTo) { FaceSet newFaces; FaceSet droppedFaces; m_geometry->snap(newFaces, droppedFaces, snapTo); for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) { Face* face = *it; face->setBrush(NULL); m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), face), m_faces.end()); delete face; } for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) { Face* face = *it; face->setBrush(this); m_faces.push_back(face); } rebuildGeometry(); }
void Brush::correct(float epsilon) { FaceSet newFaces; FaceSet droppedFaces; m_geometry->correct(newFaces, droppedFaces, epsilon); for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) { Face* face = *it; face->setBrush(NULL); m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), face), m_faces.end()); delete face; } for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) { Face* face = *it; face->setBrush(this); m_faces.push_back(face); } rebuildGeometry(); }
void Overlay::update( float ) { rebuildGeometry(); }
Brush::Brush(const BBoxf& worldBounds, bool forceIntegerFacePoints, const BBoxf& brushBounds, Texture* texture) : MapObject(), m_geometry(NULL), m_worldBounds(worldBounds), m_forceIntegerFacePoints(forceIntegerFacePoints) { init(); Vec3f p1, p2, p3; String textureName = texture != NULL ? texture->name() : ""; p1 = brushBounds.min; p2 = p1; p2[2] = brushBounds.max[2]; p3 = p1; p3[0] = brushBounds.max[0]; Face* front = new Face(worldBounds, m_forceIntegerFacePoints, p1, p2, p3, textureName); front->setTexture(texture); front->setBrush(this); m_faces.push_back(front); p2 = p1; p2[1] = brushBounds.max[1]; p3 = p1; p3[2] = brushBounds.max[2]; Face* left = new Face(worldBounds, m_forceIntegerFacePoints, p1, p2, p3, textureName); left->setTexture(texture); left->setBrush(this); m_faces.push_back(left); p2 = p1; p2[0] = brushBounds.max[0]; p3 = p1; p3[1] = brushBounds.max[1]; Face* bottom = new Face(worldBounds, m_forceIntegerFacePoints, p1, p2, p3, textureName); bottom->setTexture(texture); bottom->setBrush(this); m_faces.push_back(bottom); p1 = brushBounds.max; p2 = p1; p2[0] = brushBounds.min[0]; p3 = p1; p3[2] = brushBounds.min[2]; Face* back = new Face(worldBounds, m_forceIntegerFacePoints, p1, p2, p3, textureName); back->setTexture(texture); back->setBrush(this); m_faces.push_back(back); p2 = p1; p2[2] = brushBounds.min[2]; p3 = p1; p3[1] = brushBounds.min[1]; Face* right = new Face(worldBounds, m_forceIntegerFacePoints, p1, p2, p3, textureName); right->setTexture(texture); right->setBrush(this); m_faces.push_back(right); p2 = p1; p2[1] = brushBounds.min[1]; p3 = p1; p3[0] = brushBounds.min[0]; Face* top = new Face(worldBounds, m_forceIntegerFacePoints, p1, p2, p3, textureName); top->setTexture(texture); top->setBrush(this); m_faces.push_back(top); rebuildGeometry(); }