Revert "Fix things..."

This reverts commit 038fca48e1.
This commit is contained in:
DelinWorks 2022-06-16 19:39:12 +03:00
parent 038fca48e1
commit 610711a164
3 changed files with 108 additions and 80446 deletions

View File

@ -767,21 +767,21 @@ void ParticleSystem::addParticles(int count, int animationIndex, int animationCe
switch (shape.type)
{
case EmissionShapeType::POINT:
case ParticleSystem::EmissionShapeType::POINT:
{
_particleData.posx[i] = _sourcePosition.x + shape.x;
_particleData.posy[i] = _sourcePosition.y + shape.y;
break;
}
case EmissionShapeType::RECT:
case ParticleSystem::EmissionShapeType::RECT:
{
_particleData.posx[i] = _sourcePosition.x + shape.x + shape.innerWidth / 2 * _rng.rangef();
_particleData.posy[i] = _sourcePosition.y + shape.y + shape.innerHeight / 2 * _rng.rangef();
break;
}
case EmissionShapeType::RECTTORUS:
case ParticleSystem::EmissionShapeType::RECTTORUS:
{
float width = (shape.outerWidth - shape.innerWidth) * _rng.float01() + shape.innerWidth;
float height = (shape.outerHeight - shape.innerHeight) * _rng.float01() + shape.innerHeight;
@ -793,7 +793,7 @@ void ParticleSystem::addParticles(int count, int animationIndex, int animationCe
break;
}
case EmissionShapeType::CIRCLE:
case ParticleSystem::EmissionShapeType::CIRCLE:
{
auto val = _rng.float01() * shape.innerRadius / shape.innerRadius;
val = powf(val, 1 / shape.edgeBias);
@ -804,7 +804,7 @@ void ParticleSystem::addParticles(int count, int animationIndex, int animationCe
break;
}
case EmissionShapeType::TORUS:
case ParticleSystem::EmissionShapeType::TORUS:
{
auto val = _rng.float01() * shape.outerRadius / shape.outerRadius;
val = powf(val, 1 / shape.edgeBias);
@ -815,7 +815,7 @@ void ParticleSystem::addParticles(int count, int animationIndex, int animationCe
break;
}
case EmissionShapeType::TEXTURE_ALPHA_MASK:
case ParticleSystem::EmissionShapeType::TEXTURE_ALPHA_MASK:
{
auto& mask = ParticleEmissionMaskCache::getInstance()->getEmissionMask(shape.fourccId);
@ -1151,15 +1151,15 @@ void ParticleSystem::setEmissionShape(unsigned short index, EmissionShape shape)
iter->second = shape;
}
EmissionShape ParticleSystem::createMaskShape(std::string_view maskId,
ParticleSystem::EmissionShape ParticleSystem::createMaskShape(std::string_view maskId,
Vec2 pos,
Vec2 overrideSize,
Vec2 scale,
float angle)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::TEXTURE_ALPHA_MASK;
shape.type = ParticleSystem::EmissionShapeType::TEXTURE_ALPHA_MASK;
shape.fourccId = utils::fourccValue(maskId);
@ -1177,11 +1177,11 @@ EmissionShape ParticleSystem::createMaskShape(std::string_view maskId,
return shape;
}
EmissionShape ParticleSystem::createPointShape(Vec2 pos)
ParticleSystem::EmissionShape ParticleSystem::createPointShape(Vec2 pos)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::POINT;
shape.type = ParticleSystem::EmissionShapeType::POINT;
shape.x = pos.x;
shape.y = pos.y;
@ -1189,11 +1189,11 @@ EmissionShape ParticleSystem::createPointShape(Vec2 pos)
return shape;
}
EmissionShape ParticleSystem::createRectShape(Vec2 pos, Size size)
ParticleSystem::EmissionShape ParticleSystem::createRectShape(Vec2 pos, Size size)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::RECT;
shape.type = ParticleSystem::EmissionShapeType::RECT;
shape.x = pos.x;
shape.y = pos.y;
@ -1204,11 +1204,11 @@ EmissionShape ParticleSystem::createRectShape(Vec2 pos, Size size)
return shape;
}
EmissionShape ParticleSystem::createRectTorusShape(Vec2 pos, Size innerSize, Size outerSize)
ParticleSystem::EmissionShape ParticleSystem::createRectTorusShape(Vec2 pos, Size innerSize, Size outerSize)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::RECTTORUS;
shape.type = ParticleSystem::EmissionShapeType::RECTTORUS;
shape.x = pos.x;
shape.y = pos.y;
@ -1222,11 +1222,11 @@ EmissionShape ParticleSystem::createRectTorusShape(Vec2 pos, Size innerSize, Siz
return shape;
}
EmissionShape ParticleSystem::createCircleShape(Vec2 pos, float radius, float edgeBias)
ParticleSystem::EmissionShape ParticleSystem::createCircleShape(Vec2 pos, float radius, float edgeBias)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::CIRCLE;
shape.type = ParticleSystem::EmissionShapeType::CIRCLE;
shape.x = pos.x;
shape.y = pos.y;
@ -1241,11 +1241,15 @@ EmissionShape ParticleSystem::createCircleShape(Vec2 pos, float radius, float ed
return shape;
}
EmissionShape ParticleSystem::createConeShape(Vec2 pos, float radius, float offset, float angle, float edgeBias)
ParticleSystem::EmissionShape ParticleSystem::createConeShape(Vec2 pos,
float radius,
float offset,
float angle,
float edgeBias)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::CIRCLE;
shape.type = ParticleSystem::EmissionShapeType::CIRCLE;
shape.x = pos.x;
shape.y = pos.y;
@ -1260,11 +1264,14 @@ EmissionShape ParticleSystem::createConeShape(Vec2 pos, float radius, float offs
return shape;
}
EmissionShape ParticleSystem::createTorusShape(Vec2 pos, float innerRadius, float outerRadius, float edgeBias)
ParticleSystem::EmissionShape ParticleSystem::createTorusShape(Vec2 pos,
float innerRadius,
float outerRadius,
float edgeBias)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::TORUS;
shape.type = ParticleSystem::EmissionShapeType::TORUS;
shape.x = pos.x;
shape.y = pos.y;
@ -1280,16 +1287,16 @@ EmissionShape ParticleSystem::createTorusShape(Vec2 pos, float innerRadius, floa
return shape;
}
EmissionShape ParticleSystem::createConeTorusShape(Vec2 pos,
float innerRadius,
float outerRadius,
float offset,
float angle,
float edgeBias)
ParticleSystem::EmissionShape ParticleSystem::createConeTorusShape(Vec2 pos,
float innerRadius,
float outerRadius,
float offset,
float angle,
float edgeBias)
{
EmissionShape shape{};
ParticleSystem::EmissionShape shape{};
shape.type = EmissionShapeType::TORUS;
shape.type = ParticleSystem::EmissionShapeType::TORUS;
shape.x = pos.x;
shape.y = pos.y;

View File

@ -38,62 +38,25 @@ THE SOFTWARE.
NS_CC_BEGIN
/**
* @addtogroup _2d
* @{
*/
class ParticleBatchNode;
/** @struct sParticle
Structure that contains the values of each particle.
*/
struct particle_point
{
float x;
float y;
};
/**
* Particle emission shapes.
* Current supported shapes are Point, Rectangle, RectangularTorus, Circle, Torus, Cone, Cone Torus, Texture alpha
* emission mask
* @since adxe-1.0.0b8
*/
enum class EmissionShapeType
{
// Emission shape of type point
POINT,
// Emission shape of type rectangle
RECT,
// Emission shape of type rectangular torus
RECTTORUS,
// Emission shape of type circle or cone
CIRCLE,
// Emission shape of type torus or cone torus
TORUS,
// Emission shape of type texture alpha mask
TEXTURE_ALPHA_MASK
};
/**
* Particle emission shapes.
* Current supported shapes are Point, Rectangle, RectangularTorus, Circle, Torus, Cone, Cone Torus, Texture alpha
* emission mask
* @since adxe-1.0.0b8
*/
struct EmissionShape
{
EmissionShapeType type;
float x;
float y;
float innerWidth;
float innerHeight;
float outerWidth;
float outerHeight;
float innerRadius;
float outerRadius;
float coneOffset;
float coneAngle;
float edgeBias;
uint32_t fourccId;
};
enum class EmissionShapeType;
struct EmissionShape;
/**
* Particle emission mask descriptor.
@ -414,6 +377,53 @@ public:
};
/**
* Particle emission shapes.
* Current supported shapes are Point, Rectangle, RectangularTorus, Circle, Torus, Cone, Cone Torus, Texture alpha emission mask
* @since adxe-1.0.0b8
*/
enum class EmissionShapeType
{
// Emission shape of type point
POINT,
// Emission shape of type rectangle
RECT,
// Emission shape of type rectangular torus
RECTTORUS,
// Emission shape of type circle or cone
CIRCLE,
// Emission shape of type torus or cone torus
TORUS,
// Emission shape of type texture alpha mask
TEXTURE_ALPHA_MASK
};
/**
* Particle emission shapes.
* Current supported shapes are Point, Rectangle, RectangularTorus, Circle, Torus, Cone, Cone Torus, Texture alpha emission mask
* @since adxe-1.0.0b8
*/
struct EmissionShape
{
ParticleSystem::EmissionShapeType type;
float x;
float y;
float innerWidth;
float innerHeight;
float outerWidth;
float outerHeight;
float innerRadius;
float outerRadius;
float coneOffset;
float coneAngle;
float edgeBias;
uint32_t fourccId;
};
//* @enum
enum
{
@ -1256,7 +1266,7 @@ public:
* @param scale Scale of the emission mask, the size will be multiplied by the specified scale.
* @param angle Angle of the sampled points to be rotated in degrees.
*/
static EmissionShape createMaskShape(std::string_view maskId,
static ParticleSystem::EmissionShape createMaskShape(std::string_view maskId,
Vec2 pos = Vec2::ZERO,
Vec2 overrideSize = Vec2::ZERO,
Vec2 scale = Vec2::ONE,
@ -1265,20 +1275,20 @@ public:
/** Adds an emission shape of type point to the system.
* @param pos Position of the emission shape in local space.
*/
static EmissionShape createPointShape(Vec2 pos);
static ParticleSystem::EmissionShape createPointShape(Vec2 pos);
/** Adds an emission shape of type Rectangle to the system.
* @param pos Position of the emission shape in local space.
* @param size Size of the rectangle.
*/
static EmissionShape createRectShape(Vec2 pos, Size size);
static ParticleSystem::EmissionShape createRectShape(Vec2 pos, Size size);
/** Adds an emission shape of type Rectangular Torus to the system.
* @param pos Position of the emission shape in local space.
* @param innerSize Inner size offset of the rectangle.
* @param outerSize Outer size of the rectangle.
*/
static EmissionShape createRectTorusShape(Vec2 pos, Size innerSize, Size outerSize);
static ParticleSystem::EmissionShape createRectTorusShape(Vec2 pos, Size innerSize, Size outerSize);
/** Adds an emission shape of type Circle to the system.
*
@ -1291,7 +1301,7 @@ public:
* will bias towards the center of the circle more often the closer the value is to 0.0; If the value is exactly 1.0
* then there will be no bias behaviour.
*/
static EmissionShape createCircleShape(Vec2 pos, float radius, float edgeBias = 1.0F);
static ParticleSystem::EmissionShape createCircleShape(Vec2 pos, float radius, float edgeBias = 1.0F);
/** Adds an emission shape of type Cone to the system.
*
@ -1306,7 +1316,7 @@ public:
* will bias towards the center of the circle more often the closer the value is to 0.0; If the value is exactly 1.0
* then there will be no bias behaviour.
*/
static EmissionShape createConeShape(Vec2 pos,
static ParticleSystem::EmissionShape createConeShape(Vec2 pos,
float radius,
float offset,
float angle,
@ -1324,7 +1334,7 @@ public:
* will bias towards the center of the torus more often the closer the value is to 0.0; If the value is exactly 1.0
* then there will be no bias behaviour.
*/
static EmissionShape createTorusShape(Vec2 pos,
static ParticleSystem::EmissionShape createTorusShape(Vec2 pos,
float innerRadius,
float outerRadius,
float edgeBias = 1.0F);
@ -1343,7 +1353,7 @@ public:
* will bias towards the center of the torus more often the closer the value is to 0.0; If the value is exactly 1.0
* then there will be no bias behaviour.
*/
static EmissionShape createConeTorusShape(Vec2 pos,
static ParticleSystem::EmissionShape createConeTorusShape(Vec2 pos,
float innerRadius,
float outerRadius,
float offset,

File diff suppressed because it is too large Load Diff