Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
ParticleEmitter: unsigned to signed
Browse files Browse the repository at this point in the history
Related: #2940
  • Loading branch information
1vanK committed Jun 18, 2022
1 parent 7cfe697 commit bb7f22f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
20 changes: 10 additions & 10 deletions Source/Urho3D/AngelScript/Generated_Members.h
Original file line number Diff line number Diff line change
Expand Up @@ -3356,11 +3356,11 @@ template <class T> void RegisterMembers_Particle(asIScriptEngine* engine, const
// float Particle::rotationSpeed_
engine->RegisterObjectProperty(className, "float rotationSpeed", offsetof(T, rotationSpeed_));

// unsigned Particle::colorIndex_
engine->RegisterObjectProperty(className, "uint colorIndex", offsetof(T, colorIndex_));
// i32 Particle::colorIndex_
engine->RegisterObjectProperty(className, "int colorIndex", offsetof(T, colorIndex_));

// unsigned Particle::texIndex_
engine->RegisterObjectProperty(className, "uint texIndex", offsetof(T, texIndex_));
// i32 Particle::texIndex_
engine->RegisterObjectProperty(className, "int texIndex", offsetof(T, texIndex_));

#ifdef REGISTER_MEMBERS_MANUAL_PART_Particle
REGISTER_MEMBERS_MANUAL_PART_Particle();
Expand Down Expand Up @@ -24971,9 +24971,9 @@ template <class T> void RegisterMembers_ParticleEmitter(asIScriptEngine* engine,
// ResourceRef ParticleEmitter::GetEffectAttr() const
engine->RegisterObjectMethod(className, "ResourceRef GetEffectAttr() const", AS_METHODPR(T, GetEffectAttr, () const, ResourceRef), AS_CALL_THISCALL);

// unsigned ParticleEmitter::GetNumParticles() const
engine->RegisterObjectMethod(className, "uint GetNumParticles() const", AS_METHODPR(T, GetNumParticles, () const, unsigned), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "uint get_numParticles() const", AS_METHODPR(T, GetNumParticles, () const, unsigned), AS_CALL_THISCALL);
// i32 ParticleEmitter::GetNumParticles() const
engine->RegisterObjectMethod(className, "int GetNumParticles() const", AS_METHODPR(T, GetNumParticles, () const, i32), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "int get_numParticles() const", AS_METHODPR(T, GetNumParticles, () const, i32), AS_CALL_THISCALL);

// bool ParticleEmitter::GetSerializeParticles() const
engine->RegisterObjectMethod(className, "bool GetSerializeParticles() const", AS_METHODPR(T, GetSerializeParticles, () const, bool), AS_CALL_THISCALL);
Expand Down Expand Up @@ -25007,9 +25007,9 @@ template <class T> void RegisterMembers_ParticleEmitter(asIScriptEngine* engine,
engine->RegisterObjectMethod(className, "void SetEmitting(bool)", AS_METHODPR(T, SetEmitting, (bool), void), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "void set_emitting(bool)", AS_METHODPR(T, SetEmitting, (bool), void), AS_CALL_THISCALL);

// void ParticleEmitter::SetNumParticles(unsigned num)
engine->RegisterObjectMethod(className, "void SetNumParticles(uint)", AS_METHODPR(T, SetNumParticles, (unsigned), void), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "void set_numParticles(uint)", AS_METHODPR(T, SetNumParticles, (unsigned), void), AS_CALL_THISCALL);
// void ParticleEmitter::SetNumParticles(i32 num)
engine->RegisterObjectMethod(className, "void SetNumParticles(int)", AS_METHODPR(T, SetNumParticles, (i32), void), AS_CALL_THISCALL);
engine->RegisterObjectMethod(className, "void set_numParticles(int)", AS_METHODPR(T, SetNumParticles, (i32), void), AS_CALL_THISCALL);

// void ParticleEmitter::SetSerializeParticles(bool enable)
engine->RegisterObjectMethod(className, "void SetSerializeParticles(bool)", AS_METHODPR(T, SetSerializeParticles, (bool), void), AS_CALL_THISCALL);
Expand Down
32 changes: 16 additions & 16 deletions Source/Urho3D/Graphics/ParticleEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Urho3D

extern const char* GEOMETRY_CATEGORY;
extern const char* faceCameraModeNames[];
static const unsigned MAX_PARTICLES_IN_FRAME = 100;
static const i32 MAX_PARTICLES_IN_FRAME = 100;

extern const char* autoRemoveModeNames[];

Expand Down Expand Up @@ -131,7 +131,7 @@ void ParticleEmitter::Update(const FrameInfo& frame)
if (emissionTimer_ < -intervalMax)
emissionTimer_ = -intervalMax;

unsigned counter = MAX_PARTICLES_IN_FRAME;
i32 counter = MAX_PARTICLES_IN_FRAME;

while (emissionTimer_ > 0.0f && counter)
{
Expand All @@ -153,7 +153,7 @@ void ParticleEmitter::Update(const FrameInfo& frame)
if (scaled_ && !relative_)
scaleVector = node_->GetWorldScale();

for (unsigned i = 0; i < particles_.Size(); ++i)
for (i32 i = 0; i < particles_.Size(); ++i)
{
Particle& particle = particles_[i];
Billboard& billboard = billboards_[i];
Expand Down Expand Up @@ -206,7 +206,7 @@ void ParticleEmitter::Update(const FrameInfo& frame)
}

// Color interpolation
unsigned& index = particle.colorIndex_;
i32& index = particle.colorIndex_;
const Vector<ColorFrame>& colorFrames_ = effect_->GetColorFrames();
if (index < colorFrames_.Size())
{
Expand All @@ -222,7 +222,7 @@ void ParticleEmitter::Update(const FrameInfo& frame)
}

// Texture animation
unsigned& texIndex = particle.texIndex_;
i32& texIndex = particle.texIndex_;
const Vector<TextureFrame>& textureFrames_ = effect_->GetTextureFrames();
if (textureFrames_.Size() && texIndex < textureFrames_.Size() - 1)
{
Expand Down Expand Up @@ -261,10 +261,10 @@ void ParticleEmitter::SetEffect(ParticleEffect* effect)
MarkNetworkUpdate();
}

void ParticleEmitter::SetNumParticles(unsigned num)
void ParticleEmitter::SetNumParticles(i32 num)
{
// Prevent negative value being assigned from the editor
if (num > M_MAX_INT)
if (num < 0)
num = 0;

particles_.Resize(num);
Expand Down Expand Up @@ -349,7 +349,7 @@ ResourceRef ParticleEmitter::GetEffectAttr() const

void ParticleEmitter::SetParticlesAttr(const VariantVector& value)
{
unsigned index = 0;
i32 index = 0;
SetNumParticles(index < value.Size() ? value[index++].GetUInt() : 0);

for (Vector<Particle>::Iterator i = particles_.Begin(); i != particles_.End() && index < value.Size(); ++i)
Expand All @@ -360,8 +360,8 @@ void ParticleEmitter::SetParticlesAttr(const VariantVector& value)
i->timeToLive_ = value[index++].GetFloat();
i->scale_ = value[index++].GetFloat();
i->rotationSpeed_ = value[index++].GetFloat();
i->colorIndex_ = (unsigned)value[index++].GetInt();
i->texIndex_ = (unsigned)value[index++].GetInt();
i->colorIndex_ = value[index++].GetInt();
i->texIndex_ = value[index++].GetInt();
}
}

Expand Down Expand Up @@ -428,8 +428,8 @@ void ParticleEmitter::OnSceneSet(Scene* scene)

bool ParticleEmitter::EmitNewParticle()
{
unsigned index = GetFreeParticle();
if (index == M_MAX_UNSIGNED)
i32 index = GetFreeParticle();
if (index == NINDEX)
return false;
assert(index < particles_.Size());
Particle& particle = particles_[index];
Expand Down Expand Up @@ -528,20 +528,20 @@ bool ParticleEmitter::EmitNewParticle()
return true;
}

unsigned ParticleEmitter::GetFreeParticle() const
i32 ParticleEmitter::GetFreeParticle() const
{
for (unsigned i = 0; i < billboards_.Size(); ++i)
for (i32 i = 0; i < billboards_.Size(); ++i)
{
if (!billboards_[i].enabled_)
return i;
}

return M_MAX_UNSIGNED;
return NINDEX;
}

bool ParticleEmitter::CheckActiveParticles() const
{
for (unsigned i = 0; i < billboards_.Size(); ++i)
for (i32 i = 0; i < billboards_.Size(); ++i)
{
if (billboards_[i].enabled_)
{
Expand Down
10 changes: 5 additions & 5 deletions Source/Urho3D/Graphics/ParticleEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ struct Particle
/// Rotation speed.
float rotationSpeed_;
/// Current color animation index.
unsigned colorIndex_;
i32 colorIndex_;
/// Current texture animation index.
unsigned texIndex_;
i32 texIndex_;
};

/// %Particle emitter component.
Expand All @@ -55,7 +55,7 @@ class URHO3D_API ParticleEmitter : public BillboardSet
void SetEffect(ParticleEffect* effect);
/// Set maximum number of particles.
/// @property
void SetNumParticles(unsigned num);
void SetNumParticles(i32 num);
/// Set whether should be emitting. If the state was changed, also resets the emission period timer.
/// @property
void SetEmitting(bool enable);
Expand All @@ -80,7 +80,7 @@ class URHO3D_API ParticleEmitter : public BillboardSet

/// Return maximum number of particles.
/// @property
unsigned GetNumParticles() const { return particles_.Size(); }
i32 GetNumParticles() const { return particles_.Size(); }

/// Return whether is currently emitting.
/// @property
Expand Down Expand Up @@ -112,7 +112,7 @@ class URHO3D_API ParticleEmitter : public BillboardSet
/// Create a new particle. Return true if there was room.
bool EmitNewParticle();
/// Return a free particle index.
unsigned GetFreeParticle() const;
i32 GetFreeParticle() const;
/// Return whether has active particles.
bool CheckActiveParticles() const;

Expand Down

0 comments on commit bb7f22f

Please sign in to comment.