Skip to content

SpriteBatch with a source/dest rect works different then Windows #563

Closed
Limanima opened this Issue Jul 3, 2012 · 10 comments

6 participants

@Limanima
Limanima commented Jul 3, 2012

I'm reporting this as an issue, because I'm almost certain there's a problem with SpriteBatch when a source / destination rect are used with a origin.
I have an object that I want to rotate around it's center. The destination is 5 times the size of the source. What is happening is that when the destination rect is different then the source, the rotation origin changes and the object doesn't rotate around it's center anymore.
I'm almost certain there's a problem, because I've inspect the inputs for the SpriteBatch.Draw call on both Windows and Mac, and the values are exactly the same.
In windows the object rotates nicely in the center, on Mac, the objects rotates like the earth around the sun.

Here's the method with the issue:

public void Draw (Texture2D texture,
Rectangle destinationRectangle,
Nullable sourceRectangle,
Color color,
float rotation,
Vector2 origin,
SpriteEffects effect,
float depth)

Strange is that after inspecting this method I don't know how the Windows version works! It shoudn't I guess.
I have a fix for Mac, all I have to do is to multiply the origin by the scale before the call to SpriteBatch.

@Limanima
Limanima commented Jul 5, 2012

Let me add this: when I say "windows" I mean XNA in windows, and not MonoGame in windows.

@espes
Mono Project member
espes commented Jul 5, 2012

Is this in the develop or develop3d branch? Does it occur in both?

@Limanima
Limanima commented Jul 6, 2012

It happens on the develop branch, didn't try it on develop3d branch.

@tomspilman
Mono Project member

We never used rotation with SpriteBatch, so its possible that could be broken. For sure it is something to test on the develop3d branch as lots has changed there.

@Limanima
Limanima commented Jul 7, 2012

Should I be using the develop3d branch instead?

@tomspilman
Mono Project member

Depends.

The develop3d branch is not finished and is a work in progress. If you can deal with things changing or breaking then I would recommend it. For our game we work off of develop3d daily and if something breaks it usually is fixed quickly.

If all you need is 2D and don't want to deal with the occasional broken build... then you should stick with develop and submit a pull request with your fix.

@Cyberqat

Source rectangles dont appear to work at all in IOS... using Draw(Textue2D,Vector2,Rectangle, Color) when I change the y source coordinate value in the rectangle the result is a size stretch on y. This suggests that either the whole parameter stack is off or its just mis-implemented.

@tomspilman
Mono Project member

I don't know about the 'develop' branch, but source rectangles do work on the 'develop3d' branch.

@Cyberqat
@xesf
xesf commented Aug 9, 2012

Just confirmed that this issue is happening in the devolop3d branch.
Edit: I'm using the MacOSX develop3d branch, btw.

@dellis1972 dellis1972 closed this in 28a309e Oct 5, 2012
@dellis1972 dellis1972 pushed a commit that referenced this issue Oct 5, 2012
@liortal53 liortal53 Fix issue #563 - moved scaling of Origin vector to the Draw() overloa…
…d that accepts a destinationRectangle.

This assures we're not breaking any overloads that DO NOT supply the destinationRectangle.
0c93a51
@zyphrus zyphrus pushed a commit that referenced this issue Oct 18, 2014
@liortal53 liortal53 Fix issue #563 - moved scaling of Origin vector to the Draw() overloa…
…d that accepts a destinationRectangle.

This assures we're not breaking any overloads that DO NOT supply the destinationRectangle.
496b89e
@zyphrus zyphrus pushed a commit that referenced this issue Oct 18, 2014
@liortal53 liortal53 Fix issue #563 - moved scaling of Origin vector to the Draw() overloa…
…d that accepts a destinationRectangle.

This assures we're not breaking any overloads that DO NOT supply the destinationRectangle.
7897e55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.