inline void _AddTexToRender( RenderList& renlist, TexID tex, int left, int top, int width, int height ) { renlist.emplace_back(); RenderEntry& entry = renlist.back(); entry.textures.push_back( tex ); entry.SetScrPos( left, top ); entry.SetSize( width, height ); }
void ObjectRenderer::renderGeometry(Geometry* geom, const glm::mat4& modelMatrix, GameObject* object, RenderList& outList) { for (SubGeometry& subgeom : geom->subgeom) { bool isTransparent = false; Renderer::DrawParameters dp; dp.colour = {255, 255, 255, 255}; dp.count = subgeom.numIndices; dp.start = subgeom.start; dp.textures = {0}; dp.visibility = 1.f; if (object && object->type() == GameObject::Instance) { auto modelinfo = object->getModelInfo<SimpleModelInfo>(); dp.depthWrite = !(modelinfo->flags & SimpleModelInfo::NO_ZBUFFER_WRITE); } if (geom->materials.size() > subgeom.material) { Geometry::Material& mat = geom->materials[subgeom.material]; if (!mat.textures.empty()) { auto tex = mat.textures[0].texture; if (tex) { if (tex->isTransparent()) { isTransparent = true; } dp.textures = {tex->getName()}; } } if ((geom->flags & RW::BSGeometry::ModuleMaterialColor) == RW::BSGeometry::ModuleMaterialColor) { dp.colour = mat.colour; if (object && object->type() == GameObject::Vehicle) { auto vehicle = static_cast<VehicleObject*>(object); if (dp.colour.r == 60 && dp.colour.g == 255 && dp.colour.b == 0) { dp.colour = glm::u8vec4(vehicle->colourPrimary, 255); } else if (dp.colour.r == 255 && dp.colour.g == 0 && dp.colour.b == 175) { dp.colour = glm::u8vec4(vehicle->colourSecondary, 255); } } } dp.visibility = 1.f; if (dp.colour.a < 255) { isTransparent = true; } dp.diffuse = mat.diffuseIntensity; dp.ambient = mat.ambientIntensity; } dp.blend = isTransparent; glm::vec3 position(modelMatrix[3]); float distance = glm::length(m_camera.position - position); float depth = (distance - m_camera.frustum.near) / (m_camera.frustum.far - m_camera.frustum.near); outList.emplace_back( createKey(isTransparent, depth * depth, dp.textures), modelMatrix, &geom->dbuff, dp); } }