FTransform UPaperSprite::GetPivotToWorld() const { const FVector2D Pivot = GetPivotPosition(); const FVector2D SourceDims = (SourceTexture != NULL) ? FVector2D(SourceTexture->GetSurfaceWidth(), SourceTexture->GetSurfaceHeight()) : FVector2D::ZeroVector; const FVector Translation((Pivot.X * PaperAxisX) + ((SourceDims.Y - Pivot.Y) * PaperAxisY)); return FTransform(Translation); }
void GuiItem::DrawDebug() { image.DrawDebug(); iPoint tmp = GetPivotPosition(); App->render->DrawQuad({ tmp.x, tmp.y, 2, 2 }, 0, 255, 0, 1000, true, false); }
iPoint Entity::GetBlitPosition() const { fPoint tmp = GetPivotPosition(); iPoint ret(tmp.x, tmp.y); ret.x -= sprite_pivot.x; ret.y -= sprite_pivot.y; return ret; }
FVector UPaperSprite::ConvertPivotSpaceToTextureSpace(FVector Input) const { const FVector2D Pivot = GetPivotPosition(); const float X = Input.X + Pivot.X; const float Z = -Input.Z + Pivot.Y; return FVector(X, Input.Y, Z); }
FVector2D UPaperSprite::ConvertPivotSpaceToTextureSpace(FVector2D Input) const { const FVector2D Pivot = GetPivotPosition(); const float X = Input.X + Pivot.X; const float Y = -Input.Y + Pivot.Y; return FVector2D(X, Y); }
SDL_Rect Entity::GetPlayerRect() const { //NOTE: this may be adapted when we use colliders fPoint blit = GetPivotPosition(); blit.x -= pivot.x; blit.y -= pivot.y; return{ blit.x, blit.y, collider_rect.w, collider_rect.h }; }
void UPaperSprite::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { //@TODO: Determine when these are really needed! TComponentReregisterContext<UPaperRenderComponent> ReregisterStaticComponents; TComponentReregisterContext<UPaperAnimatedRenderComponent> ReregisterAnimatedComponents; // Update the pivot if (PivotMode != ESpritePivotMode::Custom) { CustomPivotPoint = GetPivotPosition(); } // Look for changed properties const FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None; bool bRenderDataModified = false; bool bCollisionDataModified = false; bool bBothModified = false; if ((PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, SpriteCollisionDomain)) || (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, BodySetup3D)) || (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, CollisionGeometry)) ) { bCollisionDataModified = true; } // Properties inside one of the geom structures (we don't know which one) // if ((PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, GeometryType)) || // (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, AlphaThreshold)) || // ) // BoxSize // BoxPosition // Vertices // VertexCount // Polygons // { bBothModified = true; // } if ((PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, SourceUV)) || (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, SourceDimension)) || (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, SourceTexture)) || (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, CustomPivotPoint)) || (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperSprite, PivotMode)) ) { bBothModified = true; } if (bCollisionDataModified || bBothModified) { RebuildCollisionData(); } if (bRenderDataModified || bBothModified) { RebuildRenderData(); } Super::PostEditChangeProperty(PropertyChangedEvent); }