World: r3wp
[View] discuss view related issues
older newer | first last |
Anton 29-Aug-2010 [10180] | Check out this doc from 2007 as well. http://anton.wildit.net.au/rebol/doc/flatten-panel.txt |
JoshF 29-Aug-2010 [10181] | Hi! Thanks for the replies! Sunanda, I am using stylize (as shown in the example below). Anton, I don't mind having a panel because I need to keep the data grouped to access it generically after the user has set values. Here is a better example showing what I'm trying to do. Essentially, I want to create an "aggregate" widget using a styled panel, then initialize its elements the same way as is done for the built-in VID styles: REBOL [Title: "Node Property Sheet" Author: oofoe] ; This example will not actually work as intended. s: stylize [ title: vtext red 256 label: text 64 gpath: panel [ across label "Path:" field 150 "Unspecified" button "..." 30] gint: panel [across label "Integer:" field 50 "0"] gnumber: panel [across label "Number:" field 75 "0.0"] ] view layout/size [ styles s title "Project Settings" gpath "main" %. ; <-- I want to just specify the label text and value. gint "width" 1024 gint "height" 768 gnumber "fps" 23.97 ] 384x256 The nice thing about this (from my perspective) is that I can iterate through the property panel fields, find any recongized styles and pickup their values (that have been set by the user) using a hacked version of get-face. Am I making sense? I just feel that there should be a way to set relevant panel values when you're using the style. Thanks! |
Anton 29-Aug-2010 [10182] | It definitely makes sense, and I wanted to do this many times myself, but I just never got around to doing it. |
JoshF 29-Aug-2010 [10183x2] | It seems like the "do-facets" section in the "layout" source is the key (or close to the key) for doing this. There *is* a generic system for handling this, but it's not documented (!) and the layout source is far too clever for me to easily figure it out... ; - ) |
Possibly a style should define a function that is used by layout to set it's values. If so, I can do that with "with" and the problem is solved... | |
Anton 29-Aug-2010 [10185x4] | Yep, LAYOUT style-specific sub-dialects are possible by messing with the MULTI facet, or with the WORDS facet. |
or better, with the FACETS facet. | |
Try this: | |
stylize/master [ gint: panel [across label 200 field] with [ multi: make multi [ text: func [face blk][ ; <- strings if pick blk 1 [ print ["Text:" mold blk/1] ; Do nothing (prevents the default PANEL/MULTI/TEXT from setting the panel's face text). ; print mold get in svv/vid-styles/PANEL/multi 'text ] ] size: func [face blk][ ; <- pairs and integers if pick blk 1 [ if integer? pick blk 1 [ print ["Integer:" blk/1] ; Do nothing. ; I was going to set the integer field's text to this number directly, but the panel's ; subfaces haven't been created (in its PANE) at the time the MULTI functions are processed. ; So then I thought I'd use FACE/DATA to store this value and then set the field's text ; later in INIT, but thought better of it, since I found it's easier to parse FACETS, ; and I don't feel comfortable using the panel's DATA facet to store a value of only ; one of its subfaces. ;face/data: blk/1 ] ] ] ] append init [ ;?? texts ;?? facets context [ lbl: pane/1 fld: pane/2 foreach val facets [ case [ string? val [lbl/text: val] integer? val [fld/text: form val] ] ] ] ] ] ] view window: layout [ gint "Elephants to invite" 481 gint "Peanuts / elephant" 5000 btn "Calc" ] | |
JoshF 29-Aug-2010 [10189x3] | OK... Hang on, I'm just trying to figure understand all this... So the "facets" value inside the init/context is just the arguments to the style in the original layout? |
Thank for the example, Anton! Mind: Blown. I know Kung-f... I mean, how VID initialization works! Here's my cleaned up (and working!) test program. It should be a little more generic than your example, since it will set values until it runs out of facets or pane items. Label styles are treated specially though, as you can see. Maybe now I can fix their set-face method... REBOL [Title: "Node Property Sheet" Author: oofoe] ; Special thanks to Anton on altme/Rebol/View! s: stylize [ title: vtext red 256 label: text 64 agg: panel with [ multi: make multi [ text: func [face blk][] size: func [face blk][] decimal: func [face blk][] ] append init [ context [ p: pane f: facets while [all [not tail? p not tail? f]] [ either 'label = p/1/style [ p/1/text: f/1 ] [ set-face p/1 f/1 ] p: next p f: next f ] ] ] ] gpath: agg [ across label "Path:" field 150 "Unspecified" button "..." 30] gint: agg [across label "Integer:" field 50 "0"] gnumber: agg [across label "Number:" field 75 "0.0"] ] view layout [ styles s title "Project Settings" gpath "main" %. w: gint "width" 1024 h: gint "height" 768 gnumber "fps" 23.97 ] This is so cool! I am excited! | |
Here's the agg style with get-face doing what I want (returning the field name with everything else in a list, suitable for dropping into a key/value list): agg: panel with [ multi: make multi [ text: func [face blk][] size: func [face blk][] decimal: func [face blk][] ] append init [ context [ p: pane f: facets while [all [not tail? p not tail? f]] [ either 'label = p/1/style [ p/1/text: f/1 ] [ set-face p/1 f/1 ] p: next p f: next f ] ] ] access/get-face*: func [face /local p label x] [ p: face/pane label: to-word p/1/text p: next p x: copy [] while [not tail? p] [append x get-face p/1 p: next p] return reduce [label x] ] ] | |
Anton 30-Aug-2010 [10192] | Well, thankyou for asking the question. It's nice to see your working result, too. |
Maxim 31-Aug-2010 [10193x5] | shape collisions :-D a little milestone in my rebol game development kit... The first version of an SAT-based collisions lib for arbitrary convex polygon is now fully functional: test it in action in this test script: do http://www.pointillistic.com/open-REBOL/moa/files/ctest-preboled.r note that it handles shape rotation which isn't always supported in implementations of this algorithm on other platforms. |
the SAT (Separating Axis Theorem) algorithm is even optimised so it only manages the edges facing each other. the result will be several times faster since we end up only comparing (at a maximum) half the edges of each polygon ( for two boxes this ends up being 2^2+2^2 (8) as opposed to 4^2+4^2 (32)comparisons. for a triangle and a box, it could even end up being as little as 1^2+2^2 (5) instead of 3^2+4^2 (25). the advantage of the SAT algorithm is that its reasonably fast and is an early opt-out loop, so the moment we find a single comparison which is negative, we can positively ignore all the rest. this means that it scales pretty well, when polygons aren't close to each other or when they are small. | |
next step is implementation of the gross-level polygon proximity test (a fast algorythm ignoring polygons which are too far away). this allows many polygons to live in the same scene without requiring collision tests for them. I'll probably use a double linked-list for X and Y sorting of polygons. this allows us to start at our position directly and spread the search on each side of the list (in both directions). | |
has anyone played around with SAT systems before? or with spatial sorting algorithms? | |
I have questions about the most adapted spatial sort algorithm to use in REBOL | |
Oldes 31-Aug-2010 [10198] | Nice work.. it would be even more interesting if Cyphre's JIT could be used to speed up some of your functions one day. |
Maxim 31-Aug-2010 [10199x2] | yes I was thinking about it, especially since most of the CPU intensive code is highly compilable. |
one thing which is nice in the current system is that I'm not using pairs, but blocks of two float values, so a part from the actual AGG coordinates, everything is floating point and quite precise. | |
Gregg 31-Aug-2010 [10201] | Nice work Max. |
AdrianS 31-Aug-2010 [10202] | Yeah, looks good - do you have any guess how this would compare with Algodoo (speed-wise) once you're done? It does use OpenGL, but I guess you could too. http://www.algodoo.com/ |
Maxim 31-Aug-2010 [10203x3] | right now, I'm still flushing out the raw maths, but somehow, AGG always seems to squash any speed gains I get out of better interpreter speed. |
sometimes doubling the number of elements makes the refresh 10 times slower, sometimes, there is no noticeable difference. I'm still trying to find the best way to render things. my guess is the GC is constantly interfering since the draw blocks have to be rebuilt over and over. which is still my main issue wrt using draw in R2 and even R3. if i forego of rendering, there seems to be no noticeable effect of processing the collisions, so I hope, its not just "a trick of the light" and that my current wip (handling collisions between many polys) is going to work well. | |
Using R3 with stuff compiled and sidestepping draw in order to use AGG directly would probably allow several hundred frames per second for this simple test. | |
Maxim 1-Sep-2010 [10206] | algodoo is cool :-) |
AdrianS 1-Sep-2010 [10207] | do you have any idea why your demo limits itself to 32 fps? It does this on my system and Sunanda's so it makes me think that it's an internally imposed limit. |
Maxim 1-Sep-2010 [10208x4] | its the maximum timer resolution possible in R2 view. |
it might be possible to use a callback and allocate our own OS timer via library calls, but I think it not worth the hassle. going past 32 fps didn't produce noticeably smoother animation, and it allows much more time for (slow) math and AGG rendering in REBOL. | |
(staying at 32 fps, that is) | |
its already an issue that AGG or the GC seems to be generating a steady memory leak at each refresh, which I will have to investigate further. | |
Pekr 1-Sep-2010 [10212] | Max - interesting achievements. Do you really think, that the draw dialect interpretation is the culprit and performance killer? IIRC Cyphre said, that time to interpret the draw block dialect is really negligible ... |
Maxim 1-Sep-2010 [10213] | right now, one thing is sure, the fact that I have to go thru rendering "passes" for each part of the rendering slows down the rendering a lot. the actual number of strokes doesn't affect the rendering as much. trying to compile all the dynamic graphics into a big block is also affecting performance. but each individual group of elements is rendering at under 1% cpu. rendering three passes jumps the cpu to 20%!!! reducing/composing the passes together is almost as slow as seperate passes, sometimes even more. i am rendering at least 32 fps. If I have to rebuild a 50kb draw block at each render, the interpreter is "spinning air" redoing things over and over, allocating intermediate blocks for not much real reason, because in this case... the shapes actually change even comming into/out of existence dynamically. I can't just use static binding, the actual drawing is changing. |
Pekr 1-Sep-2010 [10214] | allocating intermediate blocks for not much real reason ... - so how would you do it? If I understand it correctly - if you want to use a dialect, you have to go via its interpretation, so I wonder if it can be improved ... |
Maxim 1-Sep-2010 [10215] | from a normal REBOLer's perspective I don't see any different way. Don't get me wrong, draw and gobs are usefull and cool. plus, in R3 there is some optimisations by using GOBs afaik. but for fast Gaming, I'd completely forget about gobs, and draw and just allow access to the AGG C functions as commands in REBOL. rasterized and displayed in a window's bitmap directly. |
Pekr 1-Sep-2010 [10216] | but you have that, no? |
Maxim 1-Sep-2010 [10217] | I've looked (briefly) in the A104 R3 host C code and it doesn't seem like it by what I understood of the extensions I found. cyphre might illuminate me if I just missed it. |
Pekr 1-Sep-2010 [10218] | Max - so far, all AGG functions are mapped just like commands, nothing more. Cyphre is working on a dialect right now, but it is not in-there. Each dialect keyword then maps to such a function - or how do you think the REBOL to AGG mapping is done? |
Maxim 1-Sep-2010 [10219x2] | they are called via the command launcher, which is used within the draw command, not directly from rebol. the elements aren't exported from the extension module. |
for some reason, the text command was exported, and when I tried to use it, it just crashed R3. the whole system requires you to tell it where to draw stuff. all the C code expects either a gob! or a low level AGG graphics object. | |
Pekr 1-Sep-2010 [10221] | ah, I understand now ... I thought that each low level function is directly mapped via a command ... |
Maxim 1-Sep-2010 [10222x2] | the issue is mostly that they need to know where to draw themselves. which is not something I've seen refered to anywhere outside of the higher level draw commands and AGG calls. |
so either there is a little magic trick to set a gob! as the current default rendering target, or there isn't any way to do this yet. | |
Pekr 1-Sep-2010 [10224] | We should ask Cyphre then .... I think that you might discuss all your concerns with him, maybe together you will find out something generally usefull :-) |
Maxim 1-Sep-2010 [10225x2] | my use cases tend to be on the fringes ;-) but I don't want to impede their plan right now. i can actually do (some/all?) of this work myself, since it would effectively be a completely separate rendering process than /view, I woudn't be competing with their efforts, it could just be an additional extension which uses the same AGG code, but with a different REBOL interface |
I would also like to build my OpenGL extension, now that I have everthing required in the extension API to start work on that. | |
Pekr 1-Sep-2010 [10227] | Would you need a vector! type for your work? IIRC vectors are still not finished in R3, no? Dunno if extensions support them .... |
Maxim 1-Sep-2010 [10228x2] | yes vector! is usefull, simply for speed considerations. not sure either, if they where added back in A101/102 |
MAJOR milestone for Game kit. test app updated and includes multiple shape collisions and propagation. quite fun :-) also: press g to view spatial sorting grid, its a bit mesmerizing to see do http://www.pointillistic.com/open-REBOL/moa/files/ctest-preboled.r | |
older newer | first last |