mirror of https://github.com/axmolengine/axmol.git
Avoid unnecessary copying of memory.
This commit is contained in:
parent
503a5bb1e4
commit
b670066756
|
@ -848,21 +848,23 @@ void ParticleSystem::addParticles(int count, int animationIndex, int animationCe
|
||||||
}
|
}
|
||||||
case EmissionShapeType::ALPHA_MASK:
|
case EmissionShapeType::ALPHA_MASK:
|
||||||
{
|
{
|
||||||
|
auto& mask = ParticleEmissionMaskCache::getInstance()->getEmissionMask(shape.maskName);
|
||||||
|
|
||||||
Vec2 pos = {shape.x, shape.y};
|
Vec2 pos = {shape.x, shape.y};
|
||||||
Vec2 size = shape.mask.size;
|
Vec2 size = mask.size;
|
||||||
Vec2 overrideSize = {shape.innerWidth, shape.innerHeight};
|
Vec2 overrideSize = {shape.innerWidth, shape.innerHeight};
|
||||||
Vec2 scale = {shape.outerWidth, shape.outerHeight};
|
Vec2 scale = {shape.outerWidth, shape.outerHeight};
|
||||||
float angle = shape.coneOffset;
|
float angle = shape.coneOffset;
|
||||||
|
|
||||||
if (overrideSize.isZero())
|
if (overrideSize.isZero())
|
||||||
overrideSize = shape.mask.size;
|
overrideSize = mask.size;
|
||||||
|
|
||||||
Vec2 point = {0, 0};
|
Vec2 point = {0, 0};
|
||||||
|
|
||||||
{
|
{
|
||||||
int rand0 = RANDOM_KISS_ABS() * shape.mask.points.size();
|
int rand0 = RANDOM_KISS_ABS() * mask.points.size();
|
||||||
int index = MIN(rand0, shape.mask.points.size() - 1);
|
int index = MIN(rand0, mask.points.size() - 1);
|
||||||
point = shape.mask.points[index];
|
point = mask.points[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
point -= size / 2;
|
point -= size / 2;
|
||||||
|
@ -1192,7 +1194,7 @@ EmissionShape ParticleSystem::createMaskShape(std::string_view maskName,
|
||||||
|
|
||||||
shape.type = EmissionShapeType::ALPHA_MASK;
|
shape.type = EmissionShapeType::ALPHA_MASK;
|
||||||
|
|
||||||
shape.mask = ParticleEmissionMaskCache::getInstance()->getEmissionMask(maskName);
|
shape.maskName = maskName;
|
||||||
|
|
||||||
shape.x = pos.x;
|
shape.x = pos.x;
|
||||||
shape.y = pos.y;
|
shape.y = pos.y;
|
||||||
|
|
|
@ -98,7 +98,7 @@ struct EmissionShape
|
||||||
float coneAngle;
|
float coneAngle;
|
||||||
float edgeElasticity;
|
float edgeElasticity;
|
||||||
|
|
||||||
ParticleEmissionMaskDescriptor mask;
|
std::string_view maskName;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @struct ParticleAnimationDescriptor
|
/** @struct ParticleAnimationDescriptor
|
||||||
|
|
Loading…
Reference in New Issue