mirror of
https://github.com/overte-org/overte.git
synced 2025-08-13 03:30:08 +02:00
Get rid of global variable for sort
Fix rhs/lhs
This commit is contained in:
parent
395822c6cd
commit
40e802bae7
3 changed files with 11 additions and 13 deletions
|
@ -184,11 +184,6 @@ public:
|
|||
uint32_t rgba;
|
||||
};
|
||||
|
||||
static glm::vec3 zSortAxis;
|
||||
static bool zSort(const ParticleDetails& rhs, const ParticleDetails& lhs) {
|
||||
return glm::dot(rhs.position, ::zSortAxis) > glm::dot(lhs.position, ::zSortAxis);
|
||||
}
|
||||
|
||||
void RenderableParticleEffectEntityItem::updateRenderItem() {
|
||||
if (!_scene) {
|
||||
return;
|
||||
|
@ -201,7 +196,7 @@ void RenderableParticleEffectEntityItem::updateRenderItem() {
|
|||
auto xcolor = _particleColors[i];
|
||||
auto alpha = (uint8_t)(glm::clamp(_particleAlphas[i] * getLocalRenderAlpha(), 0.0f, 1.0f) * 255.0f);
|
||||
auto rgba = toRGBA(xcolor.red, xcolor.green, xcolor.blue, alpha);
|
||||
particleDetails.push_back(ParticleDetails(_particlePositions[i], _particleRadiuses[i], rgba));
|
||||
particleDetails.emplace_back(_particlePositions[i], _particleRadiuses[i], rgba);
|
||||
}
|
||||
|
||||
// sort particles back to front
|
||||
|
@ -210,9 +205,12 @@ void RenderableParticleEffectEntityItem::updateRenderItem() {
|
|||
auto frustum = AbstractViewStateInterface::instance()->getCurrentViewFrustum();
|
||||
|
||||
// No need to sort if we're doing additive blending
|
||||
if (_additiveBlending != true) {
|
||||
::zSortAxis = frustum->getDirection();
|
||||
qSort(particleDetails.begin(), particleDetails.end(), zSort);
|
||||
if (!_additiveBlending) {
|
||||
glm::vec3 zSortAxis = frustum->getDirection();
|
||||
std::sort(particleDetails.begin(), particleDetails.end(),
|
||||
[&](const ParticleDetails& lhs, const ParticleDetails& rhs) {
|
||||
return glm::dot(lhs.position, zSortAxis) > glm::dot(rhs.position, zSortAxis);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -106,9 +106,9 @@ ParticleEffectEntityItem::ParticleEffectEntityItem(const EntityItemID& entityIte
|
|||
EntityItem(entityItemID),
|
||||
_lastSimulated(usecTimestampNow()),
|
||||
_particleLifetimes(DEFAULT_MAX_PARTICLES, 0.0f),
|
||||
_particlePositions(DEFAULT_MAX_PARTICLES, glm::vec3(0.0f, 0.0f, 0.0f)),
|
||||
_particleVelocities(DEFAULT_MAX_PARTICLES, glm::vec3(0.0f, 0.0f, 0.0f)),
|
||||
_particleAccelerations(DEFAULT_MAX_PARTICLES, glm::vec3(0.0f, 0.0f, 0.0f)),
|
||||
_particlePositions(DEFAULT_MAX_PARTICLES, Vectors::ZERO),
|
||||
_particleVelocities(DEFAULT_MAX_PARTICLES, Vectors::ZERO),
|
||||
_particleAccelerations(DEFAULT_MAX_PARTICLES, Vectors::ZERO),
|
||||
_particleRadiuses(DEFAULT_MAX_PARTICLES, DEFAULT_PARTICLE_RADIUS),
|
||||
_radiusStarts(DEFAULT_MAX_PARTICLES, DEFAULT_PARTICLE_RADIUS),
|
||||
_radiusMiddles(DEFAULT_MAX_PARTICLES, DEFAULT_PARTICLE_RADIUS),
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
AABox(const glm::vec3& corner, const glm::vec3& dimensions);
|
||||
AABox();
|
||||
~AABox() {};
|
||||
|
||||
|
||||
void setBox(const glm::vec3& corner, const glm::vec3& scale);
|
||||
|
||||
void setBox(const glm::vec3& corner, float scale);
|
||||
|
|
Loading…
Reference in a new issue