Using DzBox3::getIntersection
Omniflux
Posts: 427
Not sure if it is the method or my understanding that is incorrect here...
The result appears to always be [0, 0, 0] for the first intersection point with both DS4 and DS6, and the DS4 SDK.
In the following example, I expect [[0, 0, -50], [0, 0, 50]]. Am I wrong in expecting this?
var oSettings = DzSettings(); Geometry.getDefaultPrimitiveOptions(Geometry.Cube, oSettings); var oNode = Geometry.createPrimitive(oSettings); var oLine = DzLine3([[0, 0, -4000], [0, 0, 4000]]); var oIntersection = oNode.getWSBoundingBox().getIntersection(oLine); print (oIntersection.intersects); print (oIntersection.firstIntersection); print (oIntersection.lastIntersection);
Executing Script... true [0,0,0] [0,0,50] Result: Script executed in 0 secs 7 msecs.

Comments
Assuming that the cube is resting on the XY plane at Z=0, centered on the Z axis, that could actually make sense? What's the bounding box for oNode?
The bounding box in that example is
[[-50,0,-50],[50,100,50]].Here is another example with the bounding box centered around the world origin, with the same result
And here is an example with the object bounding box not containing the world origin at all
The
firstIntersectionproperty is still set to the world origin.Sure looks like a bug.
DzBox3::getIntersection(...)seems like such a useful method I find it hard to believe I am the first one to have an issue with it...As no one has responded stating that I am trying to use it incorrectly, I have submitted ticket #480447 for the issue.
I do wish there was a similar method for testing a nodes geometry instead of just the bounding box.
Not the first: Some background info...
There were 2 old threads on the topic, which seem to no longer exist.
In DS v4.9.3.33,
DzBox3::getIntersection() did not work, because it returned no DzVec3 data - you can see why:Boolean : getIntersection( DzLine3 ray, DzVec3 firstIntersection, DzVec3 lastIntersection )
I see now that since DS 4.14.1.36 it has been improved to this, as you tested:
Object : getIntersection( DzLine3 ray )
I believe you are using it correctly - I agree a ticket is in order.
Me too.
I never put in a ticket for the bug in DS v4.9.3.33 because I needed a solution a.s.a.p. - so I wrote RayIntersectTriangle/Facet/AABB/etc. functions in DAZ Script: See attached RayIntersect.txt extracts from my library. The reason I have posted this code is because I've found it surprisingly fast, and has it been good enough for my purposes so far. I'm sure you can improve the code a lot.
mCasual (of course) has both scripted and plug-in solutions relating to this:
https://sites.google.com/site/mcasualsdazscripts/mcjcollider-plugin
https://sites.google.com/site/mcasualsdazscripts9/mcjscriptedcollider
This is the funniest thing I've heard in the last decade.
Well... I wasn't thinking of the algorithms (which aren't mine), or the vector maths (also not mine), but I thought you may want to replace the for() loops with that funky JavaScript forEach() stuff, etc.
Then I had a look and found that the code I posted contains no for() loops, and no while() loops.
Sorry.
Perhaps you could standardize the capitalization of the symbol names, and/or weed and improve the excessive commentary? :)
They still exist however they offer no help. I don't recall if I submitted a ticket.
https://www.daz3d.com/forums/discussion/66054/dzbox3-getintersection-question/p1
https://www.daz3d.com/forums/discussion/comment/7980511/#Comment_7980511
I don't have access to all my notes or code at this time. Did you try it with the line passing through the DzBox3 rather than starting/finishing inside (or on boundary) ?
Haha, I even commented in the second thread there that it was a known issue.
I cannot find either of those threads through google search though.
Yes, I did test passing though the box at a point not on the boundary. Not sure why I didn't post that as my example case though...