Hi List,
Easy question first. #refreshWorld warns not to use it often because of damage recording... but it doesn't say what to use instead. What is the correct method to mark a morph damaged?
(I'm rendering a static 3D scene with a movable camera, so I only need to redraw it on demand by the camera.)
Whenever I draw on a morph I always forget I need to offset coordinates by the morph's origin, so things end up getting drawn in the top left. I tend to open morphs in hand, so it draws correctly until I drop it back into the world.
Why does the canvas in #drawOn: have a different origin depending on if you're holding the morph or not?
"self changed" will invalidate the entire morph area. "self invalidRect: rect" will only invalid the specified rectangle.
For the second question I'm not entirely sure that's true?
For historic reasons Morphic uses global coords even though most other rendering frameworks use parent-relative coordinates (I think Cuis may have fixed that, not sure). If I write a morph that always draws starting at 0@0 then it's always drawn in the top-left screen corner (though it might not be visible there unless that area gets invalidated).
However – the HandMorph paints its submorphs into a caching canvas, so they don't have to be redrawn for every mouse move. If you never invalidate your morph then it is only drawn once into that canvas and then it *looks* like it's being dragged around. But if the morph updates, e.g. you call "self changed" in your drawOn: method (don't do that! only for testing) then you will see that even while being dragged in the hand, it will always be drawn in the top-left screen corner.
On the other hand (pun intended), if you are using OpenGL (are you?) then it's not actually drawn into the world but the 3D window is an overlay that gets moved around, and the 3D content would move with that window even though it is drawn relative to 0@0.
HTH, Vanessa
On Fri, Mar 29, 2024 at 12:23 PM Lauren Pullen drurowin@gmail.com wrote:
Hi List,
Easy question first. #refreshWorld warns not to use it often because of damage recording... but it doesn't say what to use instead. What is the correct method to mark a morph damaged?
(I'm rendering a static 3D scene with a movable camera, so I only need to redraw it on demand by the camera.)
Whenever I draw on a morph I always forget I need to offset coordinates by the morph's origin, so things end up getting drawn in the top left. I tend to open morphs in hand, so it draws correctly until I drop it back into the world.
Why does the canvas in #drawOn: have a different origin depending on if you're holding the morph or not?
On 3/29/24 14:32, Vanessa Freudenberg wrote:
"self changed" will invalidate the entire morph area. "self invalidRect: rect" will only invalid the specified rectangle.
I thought I tried that, but I might have put it on the model wrapper, not the morph. Thanks!
For the second question I'm not entirely sure that's true?
For historic reasons Morphic uses global coords even though most other rendering frameworks use parent-relative coordinates (I think Cuis may have fixed that, not sure). If I write a morph that always draws starting at 0@0 then it's always drawn in the top-left screen corner (though it might not be visible there unless that area gets invalidated).
However – the HandMorph paints its submorphs into a caching canvas, so they don't have to be redrawn for every mouse move. If you never invalidate your morph then it is only drawn once into that canvas and then it /*looks*/ like it's being dragged around. But if the morph updates, e.g. you call "self changed" in your drawOn: method (don't do that! only for testing) then you will see that even while being dragged in the hand, it will always be drawn in the top-left screen corner.
That explains a lot! I understand the lack of clipping is for things like shadows, but I haven't figured out why drawing is done with global coordinates.
I always forget #translateBy:during: exists when drawing, but I've previously only drawn simple things.
On the other hand (pun intended), if you are using OpenGL (are you?)Nice one.
I'm not using OpenGL, but I'm familiar with drawing to a buffer. I'm doing raycasting for a 3D maze game... like the screen saver on my old computer... but entirely in Smalltalk. It should be simple, but so far I've gotten a segmentation fault from drawing primitives and a keyhole... which looks cool, but is wrong.
squeak-dev@lists.squeakfoundation.org