lars.saalbach Posted June 6, 2013 Share Posted June 6, 2013 Hey Unigine Team, I wanted to ask you, if its would be possible to provide an "AND" operation for the getIntersection functionality? So you can provide the mask like "1010010" and this mask need to match completely to the triggered element/mesh/node (at the moment its an "XOR" don't?) - this could be passed via an parameter at all, like the "exluded nodes"-array.With that you could provide much more complexer logics in game. Thanks & Greetings Lars Link to comment
frustum Posted June 23, 2013 Share Posted June 23, 2013 Can you explain what kind of logic you are trying to achieve. Because it can be an alternative solution of your problem. Right now getIntersection() provides ((object_mask & mask) != 0) test. Link to comment
lars.saalbach Posted June 25, 2013 Author Share Posted June 25, 2013 Hello frustum Currently an intersection returns true if any bit of source and target masks are matching. This is true: 00001111110001 This too: 100100100100 There is no way to validate if the whole mask is matching or only a part. For our use case we need that the mask is completely matching and not only some parts of it. ((object_mask & mask) != 0) does exactly the opposite, as soon a bit is matching its true. What also should be provided: ((object_mask ^ mask) == 0) PHP-Code for sample: $a=5; $b=1; $c=$a^$b; $d=$a^$b; echo $c; echo $d; Greetings Lars Link to comment
lars.saalbach Posted July 9, 2013 Author Share Posted July 9, 2013 Hey Frustrum, how it looks like, did the sample helped you? Greetings & a nice day Lars Link to comment
frustum Posted September 16, 2013 Share Posted September 16, 2013 Still don't know how to implement this feature seamless to the current solution. Link to comment
lars.saalbach Posted October 4, 2013 Author Share Posted October 4, 2013 Hey Frustum, maybe a complete new function "getIntersectionSecond()" - however it should be called then - would be a solution, don't know how it looks internal. Hopefully you find a good solution it would be pretty awesome! Greetings Lars Link to comment
ulf.schroeter Posted October 4, 2013 Share Posted October 4, 2013 Lars, sounds like far too specific to me, which means it should better be implemented within your own script code. Isn't it possible to use existing getIntersection( vec3 p0,vec3 p1,int mask,int exclude[],int ret[] ) with object exclude list to achieve your requirement by running the intersection testing in a loop ? For each returned nearest object intersection you could test on your own exact surface mask match. If not equal, then simply add returned object to exclude list and call getIntersection once again until you find exact mask match or no more objects are returned ? Something like (untested) .... Node node; Node excludes[]; int result[]; while( true ) { node = engine.world.getIntersection( p0, p1, mask, excludes, result ); if( node == 0 ) { break; } // some object casting and suface mask extraction based on result result[] surface index ...... int surfacemask = ...; if( surfacemask == mask ) { // success, found exact match break; } else { // mask mismatch, so search next closest object intersection excludes.append(node); } } ..... If you don't have too many objects on your intersection ray path performance shouldn't be a real problem. Link to comment
lars.saalbach Posted October 7, 2013 Author Share Posted October 7, 2013 Hello Ulf, thanks for the advanced into depth information. We already thought about this, but like you mentioned, as more objects as you get as more performance relevant it will be going. For the first implementation and for further development this will be a work arround, but with more objects and "real-time" interactions this could get a realy big bottle-neck.Greetings Lars Link to comment
ulf.schroeter Posted October 7, 2013 Share Posted October 7, 2013 Ok, so maybe general approach should be changed. Frustum already asked the key question: what are you trying to achieve on a logical level ? At the moment your requirement is just stated on a low-level technical level. Sounds like you want to use the mask value more like an index value ?!? Link to comment
manuel.gysin Posted October 9, 2013 Share Posted October 9, 2013 Our use case: Our crafting system is based in 3D-Space, this means the user has to drag and drop 3D-Objects into other objects. Sample: Taking a cup of water and move it into a bowl. Then taking an apple and put it on a chopping board. We need a fast and usable way to check if a object can interact with an other object. Because of our amount of different object types (I still mean 3D-Objects) we want to set an unique intersection mask for each object type. If getIntersection was successfully the object can be dragged or dropped. If not, just do nothing. We build the rules with static defines in the source code, if a 3D object is spawning (database driven with much meta information) we set this mask. So we have one point of configuration and one point of checking. The current getIntersection does not work in this case, because only a part of the intersection mask has to match to be true and not the whole one. I know there are other ways to do this but all alternatives I know will need much more custom code per type and more cpu time. Link to comment
ulf.schroeter Posted October 9, 2013 Share Posted October 9, 2013 Lars, thanks for the detailed description. No feeling on your specific custom code requirements, but based on your use case I wouldn't be too concerned about possible performance issues upfront. My understanding is that your tests for object interactions can be limited to a quite narrow space (let's say some meters) in 3D world space = not too big number of possibly interacting objects. Therefore some repetitive getIntersection() calls with a little bit of additional mask equality checking within your script code shouldn't be a problem. Link to comment
Recommended Posts