Rect2F SkeletonSlot::CalculateBoundingBox() { if (mAttachment != nullptr&&mAttachment->Type() == SkeletonAttachmentType::BoundingBox) { SkeletonBoundingBoxAttachmentModel* boundingBox = (SkeletonBoundingBoxAttachmentModel*)mAttachment; const List<Point2F>& vertices = boundingBox->Polygon().Vertices(); RangeF rangeX; RangeF rangeY; FOR_EACH_COLLECTION(i, vertices) { Point2F pos = *i; pos = TransformToWorld(pos); rangeX.Expand(pos.X); rangeY.Expand(pos.Y); }
void PlaySpace::castParticles(const Particle& def, Vec2F position, int amount, RangeF power, Color col, RangeF scale, RangeF lifetime, float turbulenceFactor) { for(int i = 0; i < amount; ++i) { Noise1D turbulence; turbulence.Octaves = 2; turbulence.Interval = 0.25f; Particle p(def); float angleF = gRNG.getFloat(); Angle angle = Angle::FromTurn(angleF); float angTurb = turbulence.calc(angleF); p.Colorization = col; p.Position = position; p.Size = gRNG.getNumber(scale); p.Speed = angle.toDirection() * power.interpolate(gRNG.getFloat() * ((1-turbulenceFactor) + angTurb*angTurb*turbulenceFactor)); p.Rotation = angle; p.LifeTimeMult = gRNG.getNumber(lifetime); spawnParticle(p, false); } }
Rect2F SkeletonSlot::CalculateBoundingBox() { if (mAttachment != nullptr&&mAttachment->Type() == SkeletonAttachmentType::BoundingBox) { SkeletonBoundingBoxAttachmentModel* boundingBox = (SkeletonBoundingBoxAttachmentModel*)mAttachment; const List<Point2F>& vertices = boundingBox->Polygon().Vertices(); RangeF rangeX; RangeF rangeY; for(auto pos: vertices) { pos = TransformToWorld(pos); rangeX.Expand(pos.X); rangeY.Expand(pos.Y); } return Rect2F(rangeX.Min, rangeY.Min, rangeX.Length(), rangeY.Length()); } return Rect2F::Zero; }
QDebug operator<<(QDebug dbg, const RangeF &range) { dbg.nospace() << "RangeF(" << range.min() << ", " << range.max() << ")"; return dbg.maybeSpace(); }