Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline ollimorp  
#1 Posted : Saturday, November 9, 2013 3:41:45 PM(UTC)
ollimorp

Joined: 7/22/2013(UTC)
Posts: 13

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Hi Folks,

if my problem is simple to solve, you don´t have to read further after this question:

Some of the points of my Line2D are outside it´s DrawArea. You could take a look at the attachment.
1. Is this a bug?
2. Why are this parts of Line2D won´t be cut of at the borders of the DrawArea?



Here´s my whole story, if anyone is bored ;)

I´m creating reusable UI-Components and some of them have a fix pixelsize instead of a fix ratio to the screensize.
(btw. my components with fix aspectratio are working correctly)

My placeable UI-container, inherits from the Control-class.
When resizing the window, my UI-Host(Entity) forwards the command to its containers (Control), and the containers resizes their components/childs (most of them are Entity2D) directly or indirectly.

In this example case for troubleshooting, I got following structure:
UI-Host -> 1 Sidebar (Control) on the rightside, 200px width -> 1 Line2D (the border of the sidebar)
The Line2D is extended with the ExtendedLine()-Method to a rectangle. Start-/Endpoint is the topleft-point of its container.

A short overview of the values:
At start:
Window-ViewportPixelsize: 1280/720px
ScreenSpace: RelativeScreenSpace
Sidebar-size: 200px (=1,5625) /1.0f
Sidebar-TopLeft: 0,84375 (=1280-200px) / 0.0f
Border.Start/-EndPoint (TopLeft): 0,84375 / 0.0f (Border.DrawArea is identical)


After maximizing my window, I recalculate the DrawAreas of all UI-components.
Window-ViewportPixelsize: 1600/900px
ScreenSpace: RelativeScreenSpace
Sidebar-size: 200px (=0,125)/1.0f
Sidebar-TopLeft: 0,875 (=1600-200px) / 0.0f
Border.Start/-Endpoint (TopLeft): 0,84375 / 0.0F (Didn´t changed, whereas the DrawArea of the Line2D changed to 0,875)

EDIT: On resizing, I changed the DrawArea of the Line2D with following code:
Code:
Get<Line2D>().DrawArea = DrawArea; // DrawArea belongs to the container


So the point array has got drawn elements, which are outside of it´s DrawArea, and were not updated to the new DrawArea.



Greetings

Edited by user Saturday, November 9, 2013 3:55:04 PM(UTC)  | Reason: Set markers on the important values

ollimorp attached the following image(s):
DrawArea.png (22kb) downloaded 11 time(s).

You cannot view/download attachments. Try to login or register.

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline elasto  
#2 Posted : Saturday, November 9, 2013 4:36:32 PM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
I think I understand you correctly: You're basically saying that if you change the DrawArea of a Line2D it doesn't change the start and end points - and you're right; DrawArea is initialized from the start and end points - but is not used from that point onwards.

I shall seek to fix this for you.
Offline ollimorp  
#3 Posted : Saturday, November 9, 2013 5:20:01 PM(UTC)
ollimorp

Joined: 7/22/2013(UTC)
Posts: 13

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Originally Posted by: PG Go to Quoted Post
I think I understand you correctly: You're basically saying that if you change the DrawArea of a Line2D it doesn't change the start and end points - and you're right; DrawArea is initialized from the start and end points - but is not used from that point onwards.

I shall seek to fix this for you.



Hi PG,
that´s correct. The DrawArea is smaller than the bounds of the construct.

Additionally I noticed a strange behaviour. I fixed this problem by creating a new Line2D and set it.
When I resize the border of the container...
Code:

public void Resize(DETypes.Size newVPSize)
        {
            // Ziel: 
            DrawArea = ScreenSpaceActivator.Activate<RelativeScreenSpace>().FromPixelSpace(new DETypes.Rectangle(new DETypes.Vector2D(newVPSize.Width - pixelWidthLandscape, 0f),
                                                                                                                 new DETypes.Size(pixelWidthLandscape, newVPSize.Height)));
            
            Line2D border = new Line2D(this.DrawArea.TopLeft, this.DrawArea.TopRight, DETypes.Color.White);
            border.ExtendLine(this.DrawArea.BottomRight);
            border.ExtendLine(this.DrawArea.BottomLeft);
            border.ExtendLine(this.DrawArea.TopLeft);
            border.RenderLayer = (int)RenderLayers.GuiControls2;
            
            Set(border);


... the old lines won´t disappear and were still rendered!
The debugger told me that the old border was correct overridden.

They only disappear, when I manually dispose and remove the old, and add the new border.
Code:

    Get<Line2D>().Dispose();
    Remove<Line2D>();
    Add<Line2D>(border);



Am I use the DE in a totally wrong way or is this just a fortuity? :D
Offline elasto  
#4 Posted : Saturday, November 9, 2013 5:40:42 PM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
I have fixed this locally, however I think it will need some further work yet: While changing the draw area now adjusts the positions of all points, and changing the start and end points now sets the draw area, if both the start and end points and draw area are changed within the same frame it may behave unexpectedly. To fix this I may have to make a change to Entity2D which I can't do this close to the v1.0 release.

As such, if you have a workaround (and recreating the border is a perfectly sensible workaround) then I might perhaps hold off from releasing this fix until it's bulletproof.

Also, it probably needs a little further thought from the point of view that the draw area should probably represent a bounding box for a Line2D which has multiple points. I'd like to discuss it a little further with Benjamin therefore, which should probably take place after v1.0.

---

And, yes, the behavior you note in your latest post is to be expected; Entities are persistent: Once created they will exist and do whatever they do (in this case draw a line) until made inactive or disposed. Doing 'Set(border)' just changes which Line2D is stored as a component; It doesn't actually stop the old Line2D from still existing and therefore rendering. As you correctly deduced, you need to do something like:

Get<Line2D>().Dispose();
Set(border);
thanks 1 user thanked elasto for this useful post.
ollimorp on 11/9/2013(UTC)
Offline ollimorp  
#5 Posted : Saturday, November 9, 2013 6:04:08 PM(UTC)
ollimorp

Joined: 7/22/2013(UTC)
Posts: 13

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Ok thanks. :)

Quote:
Doing 'Set(border)' just changes which Line2D is stored as a component; It doesn't actually stop the old Line2D from still existing and therefore rendering.


Shame on me. Very stupid mistake
Offline elasto  
#6 Posted : Wednesday, December 11, 2013 5:26:29 AM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
Just a quick note to say a complete solution to this has just been coded and approved for release.

Thanks again for drawing it to our attention :)
Offline Benjamin  
#7 Posted : Wednesday, December 11, 2013 5:41:21 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Check it out in the nightly releases ^^ http://deltaengine.net/download
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2018, Yet Another Forum.NET
This page was generated in 0.146 seconds.