Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upTransforms are broken -- tracking issue #435
Comments
icefoxen
added
bug
Type-CODE
labels
Jul 16, 2018
icefoxen
added this to the 0.5 milestone
Jul 16, 2018
This comment has been minimized.
This comment has been minimized.
|
shear should probably be a Vector2 also. |
This comment has been minimized.
This comment has been minimized.
|
Made a
We want to be able to support both but not at the same time. Shear can probably be gotten rid of safely tbh. As mentioned in #439 (comment) , offset and scale combine incorrectly, and the docs on offset units are incorrect. The following math for let transform = translate * offset * rotation * offset_inverse * shear * scale; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@termhn You're way better at math than me. I'll buy you a cake if you help me with this, 'cause by now it's all some twisted mess and I can't figure out what's happening where, let alone what should be happening where. I spent over an hour messing around with making the transform offset work in the range of |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Okay, so per #439 there's issues with the offset matrix calculation:
(shear omitted for simplicity) and it should be
In 0.4 that code is here, in 0.5 it is in the same file but slightly different place. So I implemented this change in 0.5 and there's TWO issues First, the offset isn't scaled properly by the size of the image, which is adjusted here. 0.4 has MOST of the desired behavior: The image is drawn from the top-left corner minus 0.5 currently has Very Wrong behavior: The image is drawn from the top-left corner ignoring offset (or ignoring scale???), rotation starts from the Also, in both versions, let real_scale = Point2::new(
src_width * param.scale.x * self.width as f32,
src_height * param.scale.y * self.height as f32,
);
let mut new_param = param;
new_param.scale = real_scale;In 0.5: let real_scale = nalgebra::Vector3::new(
src_width * f32::from(self.width),
src_height * f32::from(self.height),
1.0,
);
let new_param = param.mul(Matrix4::new_nonuniform_scaling(&real_scale));These are very different operations and that might be a source of problems, and the whole Well, progress? I need to actually write down everywhere that a transformation to the coordinate system happens in this silly system.. Frankly the transform stack system doesn't really make that any easier, though in this case I'm not even using it at all so it does nothing; it just adds another thing going on to filter out. |
This comment has been minimized.
This comment has been minimized.
|
In devel currently that doesn't happen. Which is weird since the math should be functionally identical? |
This comment has been minimized.
This comment has been minimized.
|
Fixed that at least, in an ad-hoc way, in commit 27e40bd . Text and canvases need fixing. |
This comment has been minimized.
This comment has been minimized.
|
The text stuff is happening because resizing the screen doesn't touch Also beware that |
matju
referenced this issue
Oct 21, 2018
Open
Weird scaling behaviour when creating arbitrary-sized canvases #497
This comment has been minimized.
This comment has been minimized.
|
So I tried to fiddle with this a bit and I looked at old matrix math tutorials and ended up with let transform = translate * offset * rotation * scale * offset_inverse;And it looks like what I think should be happening when I run the translations demo. The image rotates around it's "center" point while being scaled down and offset from one of the grid points. link to my fork: https://github.com/Lokathor/ggez |
This comment has been minimized.
This comment has been minimized.
|
Oh right, part of the pain in the ass is that |
added a commit
that referenced
this issue
Dec 16, 2018
This comment has been minimized.
This comment has been minimized.
|
Resolving #493 will fix this for |
This comment has been minimized.
This comment has been minimized.
|
With 19a5df0 I'm pretty sure this is closed now. \o/ The |


icefoxen commentedJul 16, 2018
This has been the case for a while and I thought "oh it's just a quick fix" and I put it off forever and tried to mess with it yesterday and couldn't fix it so it's obviously not quick so I need to stop putting it off and give it its own issue.
Basically, in
Image::draw(), theoffsetvalue is one way or another not being applied correctly.There's also the various breakage with canvases and such, and in general all the drawing transform code needs to be looked over to make sure it Actually Works Right.
This is irritating since it's kinda spread out in various places and I don't understand how it composes well enough, so blah.