void Entity::transform(const Mat4f& pointTransform, const Mat4f& vectorTransform, const bool lockTextures, const bool invertOrientation) { Vec3f newOrigin = pointTransform * origin(); setProperty(OriginKey, newOrigin, true); applyRotation(vectorTransform); invalidateGeometry(); }
void PlaneGeometry::setDoubleSided(bool value) { if (value != m_doubleSided) { m_doubleSided = value; invalidateGeometry(); } }
void SphereGeometry::setRadius(float value) { if (value != m_radius) { m_radius = value; invalidateGeometry(); } }
void PlaneGeometry::setHeight(float value) { if (value != m_height) { m_height = value; invalidateGeometry(); } }
void Entity::setDefinition(EntityDefinition* definition) { if (m_definition != NULL) m_definition->decUsageCount(); m_definition = definition; if (m_definition != NULL) m_definition->incUsageCount(); invalidateGeometry(); }
void Entity::addBrushes(const BrushList& brushes) { for (unsigned int i = 0; i < brushes.size(); i++) { Model::Brush* brush = brushes[i]; brush->setEntity(this); m_brushes.push_back(brush); } invalidateGeometry(); }
void PlaneGeometry::setMode(PlaneGeometryMode value) { if (value != m_mode) { m_mode = value; invalidateGeometry(); } }
void PlaneGeometry::setYUp(bool value) { if (value != m_yUp) { m_yUp = value; invalidateGeometry(); } }
void PlaneGeometry::setWidth(float value) { if (value != m_width) { m_width = value; invalidateGeometry(); } }
void SphereGeometry::setSegmentsW(unsigned short value) { if (value != m_segmentsW) { m_segmentsW = value; invalidateGeometry(); invalidateUVs(); } }
void PlaneGeometry::setSegmentsH(unsigned short value) { if (value != m_segmentsH) { m_segmentsH = value; invalidateGeometry(); invalidateUVs(); } }
void Entity::init() { m_map = NULL; m_worldspawn = false; m_definition = NULL; setEditState(EditState::Default); m_selectedBrushCount = 0; m_hiddenBrushCount = 0; setProperty(SpawnFlagsKey, "0"); invalidateGeometry(); }
void PointStarfield::setObserverLongitude (Ogre::Degree value) { if (!Math::RealEqual ( mObserverLongitude.valueDegrees (), value.valueDegrees (), this->getObserverPositionRebuildDelta ().valueDegrees ())) { mObserverLongitude = value; invalidateGeometry (); } }
void Entity::setProperty(const PropertyKey& key, const PropertyValue* value) { const PropertyValue* oldValue = propertyForKey(key); if (oldValue == value) return; if (oldValue != NULL && value != NULL && *oldValue == *value) return; if (key == ClassnameKey && value != classname()) { m_worldspawn = *value == WorldspawnClassname; setDefinition(NULL); } if (isNumberedProperty(TargetKey, key)) { if (oldValue != NULL && !oldValue->empty()) removeLinkTarget(*oldValue); if (value != NULL && !value->empty()) addLinkTarget(*value); if (m_map != NULL) m_map->updateEntityTarget(*this, value, oldValue); } else if (isNumberedProperty(KillTargetKey, key)) { if (oldValue != NULL && !oldValue->empty()) removeKillTarget(*oldValue); if (value != NULL && !value->empty()) addKillTarget(*value); if (m_map != NULL) m_map->updateEntityKillTarget(*this, value, oldValue); } else if (key == TargetnameKey) { removeAllLinkSources(); removeAllKillSources(); if (value != NULL && !value->empty()) { addAllLinkSources(*value); addAllKillSources(*value); } if (m_map != NULL) m_map->updateEntityTargetname(*this, value, oldValue); } if (value == NULL) m_propertyStore.removeProperty(key); else m_propertyStore.setPropertyValue(key, *value); invalidateGeometry(); }
void Entity::removeBrush(Brush& brush) { brush.setEntity(NULL); m_brushes.erase(std::remove(m_brushes.begin(), m_brushes.end(), &brush), m_brushes.end()); invalidateGeometry(); }
void Entity::addBrush(Brush& brush) { brush.setEntity(this); m_brushes.push_back(&brush); invalidateGeometry(); }
void PointStarfield::notifyStarVectorChanged () { invalidateGeometry (); }
void SphereGeometry::buildGeometry(CompactSubGeometry* target) { int numVertices = (m_segmentsH + 1) * (m_segmentsW + 1); int numIndices = (m_segmentsH - 1) * m_segmentsW * 6; int stride = target->getVertexStride(); int skip = stride - 9; float* vertices; unsigned short* indices; if (numVertices == target->getVertexCount()) { vertices = target->getVertexData(); indices = target->getIndexData(); } else { vertices = new float[numVertices * stride]; indices = new unsigned short[numIndices]; invalidateGeometry(); } unsigned short i, j, a, b, c, d; int startIndex, index = target->getVertexOffset(), triIndex = 0; float horangle, z, ringradius, verangle, x, y, normLen, tanLen, t1, t2, comp1, comp2; for (j = 0; j <= m_segmentsH; j++) { startIndex = index; horangle = MathConsts::PI * j / m_segmentsH; z = -m_radius * std::cos(horangle); ringradius = m_radius * std::sin(horangle); for (i = 0; i <= m_segmentsW; i++) { verangle = MathConsts::TWO_PI * i / m_segmentsW; x = ringradius * std::cos(verangle); y = ringradius * std::sin(verangle); normLen = 1 / std::sqrt(x * x + y * y + z * z); tanLen = std::sqrt(y * y + x * x); if (m_yUp) { t1 = 0; t2 = tanLen > .007f ? x / tanLen : 0; comp1 = -z; comp2 = y; } else { t1 = tanLen > .007f ? x / tanLen : 0; t2 = 0; comp1 = y; comp2 = z; } if (i == m_segmentsW) { vertices[index++] = vertices[startIndex]; vertices[index++] = vertices[startIndex + 1]; vertices[index++] = vertices[startIndex + 2]; vertices[index++] = vertices[startIndex + 3] + (x * normLen) * .5f; vertices[index++] = vertices[startIndex + 4] + (comp1 * normLen) * .5f; vertices[index++] = vertices[startIndex + 5] + (comp2 * normLen) * .5f; vertices[index++] = tanLen > .007f ? -y / tanLen : 1; vertices[index++] = t1; vertices[index++] = t2; } else { vertices[index++] = x; vertices[index++] = comp1; vertices[index++] = comp2; vertices[index++] = x * normLen; vertices[index++] = comp1 * normLen; vertices[index++] = comp2 * normLen; vertices[index++] = tanLen > .007f ? -y / tanLen : 1; vertices[index++] = t1; vertices[index++] = t2; } if (i > 0 && j > 0) { a = (m_segmentsW + 1) * j + i; b = (m_segmentsW + 1) * j + i - 1; c = (m_segmentsW + 1) * (j - 1) + i - 1; d = (m_segmentsW + 1) * (j - 1) + i; if (j == m_segmentsH) { vertices[index - 9] = vertices[startIndex]; vertices[index - 8] = vertices[startIndex + 1]; vertices[index - 7] = vertices[startIndex + 2]; indices[triIndex++] = a; indices[triIndex++] = c; indices[triIndex++] = d; } else if (j == 1) { indices[triIndex++] = a; indices[triIndex++] = b; indices[triIndex++] = c; } else { indices[triIndex++] = a; indices[triIndex++] = b; indices[triIndex++] = c; indices[triIndex++] = a; indices[triIndex++] = c; indices[triIndex++] = d; } } index += skip; } } target->updateData(vertices, numVertices); target->updateIndexData(indices, numIndices); }