CLIP_RECT do not take into account the rotation of the sprite before culling it

Arthur shared this bug 19 months ago
Reported

The CLIP_RECT will vanishe the Sprite it if a non-rotated variant of the size of this sprite is outside CLIP_RECT bounding Box


Rectangles were supposed to appear in the empty spaces in the image below, but as it would be "out" of the clip rect if it had no rotation, it is removed from the image

5b8ee54f2735a44b3df56314c279a446

for example, the SAME image, but if i remove the CLIP_RECT0bbd001a5715462e24ee1c080b881947

58108473ff9b70f511f07606d31712ae


In Another Example:

2079847ab34bc36bf7164c1cf929e2bc


Thanks Digi#9441 for this code for replicating

Require:

Some type of Control Seat (ensure the name is exactly "Flight Seat")

A Power Source

A Programable Block

7412011382de2cd35d9370174a3a7d98


Vector2 CursorPos;

public Program()
{
    Runtime.UpdateFrequency = UpdateFrequency.Update10;

    IMyTextSurface surface = Me.GetSurface(0);
    CursorPos = surface.SurfaceSize / 2;
}

public void Main(string argument, UpdateType updateType)
{
    IMyShipController ctrl = (IMyShipController)GridTerminalSystem.GetBlockWithName("Flight Seat");
    IMyTextSurface surface = Me.GetSurface(0);
    surface.ContentType = ContentType.SCRIPT;

    CursorPos += new Vector2(ctrl.RotationIndicator.Y, ctrl.RotationIndicator.X) * 5;

    using(var frame = surface.DrawFrame())
    {
        RectangleF viewport = new RectangleF((surface.TextureSize - surface.SurfaceSize) / 2f, surface.SurfaceSize);

        CursorPos = Vector2.Clamp(CursorPos, viewport.Center - (viewport.Size / 2), viewport.Center + (viewport.Size / 2));

        frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", viewport.Center, viewport.Size / 2));
        frame.Add(new MySprite(SpriteType.CLIP_RECT, null, viewport.Center - (viewport.Size / 4), viewport.Size / 2));

        frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", CursorPos, new Vector2(5, 100), Color.Red, rotation: MathHelper.ToRadians(45)));
        frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", CursorPos, new Vector2(100, 5), Color.Blue, rotation: MathHelper.ToRadians(45)));
    }}

both lines have 100px but the Red one have it on Y-axis, and Blue one on X-axis rotated to be 45º

d51e9793dcc43b077a627436d67075b0

The Blue one disapear if the cursor touch both ends of the Y-axis

ecdd38634250e6d7fb0625cf687f8f28

and the Red one disapear if the cursor touch both ends of the X-axis

b6dfe769d14558f4f734600ad976a97a

Replies (5)

photo
1

Hello, Arthur,

thanks for letting us know.

I seems to have and issue with reproduction of the last steps. Can you please provide more information?

How do I "touch" end with the cursor? The ends of what? With what cursor? How I can reproduce it in the game?

Can you please share me exact steps to reproduce? Also a video showing this issue will be good – there is better chance to reproduce it for me if I can see your process and repeat it on my end.

It would also eas my work if you can share whole save file right away, where everything is already set.

Please send me the save file with the affected grid, or at least a blueprint.

For saves:

You can access your save files by typing %appdata% into your Windows search bar and you will be redirected to the hidden Roaming folder. After that just follow: \Roaming\SpaceEngineers\Saves. There should be a folder with your SteamID and your saves.

Please zip the file and attach it here. If you are having difficulty attaching files you can optionally use Google Drive. When sharing a google drive link please make sure it is set to be downloadable by anyone with the link.

For blueprint:

You can access your blueprints files by typing %appdata% into your Windows search bar and you will be redirected to the hidden Roaming folder. After that just follow: \Roaming\SpaceEngineers\Blueprints. Select the correct folder where your blueprint is saved (local or cloud), zip the file and attach it here.

Thanks in advance.

Kind Regards

Keen Software House: QA Department

photo
1

> How do I "touch" end with the cursor?


this script uses the inputs of the gyroscope from the control seat, so the "Cursor" is a Vector2D based on the inputs of the movement in the user's mouse, recorded in game and changes the position of the "X" shown on the screen


> The ends of what?


The White Rectangle is the delimited area in which the "Vector2D" that represents the cursor can go

and as well, a CLIP_RECT that should ONLY prevent sprites that are OUTSIDE the inner area from being displayed, but bug itself, is that it prevents sprites that are not entirely out of the area from being displayed if any rotation is applied (as the 2 colored rectangle 45º apart that form the letter X)


> With what cursor?


your real mouse, which can is registered by the programmable block when using the control seat


> How I can reproduce it in the game?


By Building this setup and run the code above on the programable block

7412011382de2cd35d9370174a3a7d98


>Can you please share me exact steps to reproduce? Also a video showing this issue will be good


Yes, Vídeo Attached from a Space Station running Both scripts, Mine and the Demo one made by Digi


> It would also eas my work if you can share whole save file right away, where everything is already set.


Save also Attached

photo
photo
1

hello???

photo
1

IMyTextSurface surface; int X; RectangleF viewport;
public Program()
{
Runtime.UpdateFrequency = UpdateFrequency.Update10;
surface = Me.GetSurface(0);
viewport = new RectangleF((surface.TextureSize - surface.SurfaceSize) / 2f, surface.SurfaceSize);
surface.ContentType = ContentType.SCRIPT;
}
public void Main()
{ using (var frame = surface.DrawFrame())
{ X+=5; if (X > viewport.Width) X = 0;
frame.Add(new MySprite(SpriteType.CLIP_RECT, null, viewport.Center - (viewport.Size / 3), viewport.Size / 1.5f));
frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", viewport.Center, viewport.Size));
frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2(X,viewport.Center.Y), new Vector2(10, 200), Color.Blue, rotation: MathHelper.ToRadians(45)));
frame.Add(MySprite.CreateClearClipRect());
frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2(X,viewport.Center.Y), new Vector2(10, 200), new Color(0,255,0,.5f), rotation: MathHelper.ToRadians(0)));}
} 

photo
1

Hello, Arthur,

thanks for all the info and provided save.

Issue was successfully reproduced and put into our internal system.

Kind Regards

Keen Software House: QA Department

photo
1

After a little more research, I found another related problem, Sprites that inverted (X or Y as a negative value) also suffer from this problem


As usual, here's an example script, just put on a programable block and look to the screen:


IMyTextSurface surface; int X,Xp = 15; RectangleF viewport;
public Program()
{
Runtime.UpdateFrequency = UpdateFrequency.Update10;
surface = Me.GetSurface(0);
viewport = new RectangleF((surface.TextureSize - surface.SurfaceSize) / 2f, surface.SurfaceSize);
surface.ContentType = ContentType.SCRIPT;
}
public void Main()
{ using (var frame = surface.DrawFrame())
{ X+=Xp; if (X > viewport.Width || X < viewport.Position.X) Xp = -Xp;
frame.Add(new MySprite(SpriteType.CLIP_RECT, null, viewport.Center - (viewport.Size / 3), viewport.Size / 1.5f));
frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", viewport.Center, viewport.Size));
frame.Add(new MySprite(SpriteType.TEXTURE, "SquareHollow", viewport.Center, new Vector2(256, 200), Color.Red));
frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", viewport.Center, new Vector2((X-256)/2, 200), Color.Blue, alignment:TextAlignment.LEFT));
frame.Add(MySprite.CreateClearClipRect());
frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2((X+256)/2,viewport.Center.Y), new Vector2(10, 200), new Color(0,255,0,.5f)));}
}

Video Attached  

Expected.mp4 is without a clip_rect

(To do so, delete the line 12 on the code: frame.Add(new MySprite(SpriteType.CLIP_RECT, null, viewport.Center - (viewport.Size / 3), viewport.Size / 1.5f)); )

Results.mp4 is WITH a clip_rect

Leave a Comment
 
Attach a file