Jump to content

llCastRay not sensing complex mesh object from inside


animats
 Share

You are about to reply to a thread that has been inactive for 1493 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Here's a strange problem I haven't seen before, despite using huge numbers of llCastRay calls. This is messing up my NPC behavior.

truckdownwardraycast.thumb.jpg.d0241942bc11e7df1c75374e64b1601a.jpg

We're in the back of a semitrailer, doing a downward ray cast. The ray cast doesn't sense the floor.

  • The floor is solid and can be walked upon.
  • Physics model looks fine. It's "Physics type: prim".
  • Right now, the semitrailer is not physical; it becomes physical when the vehicle is started. Same problem in either mode.
  • The semitrailer is one mesh object, with solid walls and floors. That usually works fine with llCastRay.
  • I've tried other trucks, and they behave normally.

hollowcylinderraycast.jpg.cae763388693a7f4fb4e97f6ed111840.jpg

A ray cast from the box with the arrow senses the cylinder, even though it's "inside" it. Just did that as a check. Wiki says "llCastRay will not detect a prim if the line starts inside the prim. This makes it safe to use the prim position as the start location." The question is whether "inside" means "inside the solid volume" or "inside the entire object". This shows that normal behavior is to detect as when the cast starts from empty space.

Anyone seen a mesh behave this way?

 

Link to comment
Share on other sites

3 hours ago, animats said:

Wiki says "llCastRay will not detect a prim if the line starts inside the prim. This makes it safe to use the prim position as the start location." The question is whether "inside" means "inside the solid volume" or "inside the entire object".

It means inside the solid volume. More specifically, the ray will only hit the side of a face where the normal is pointing. A ray will never hit the "back" of a face, which is how it can "penetrate out" of an object. 

That said, I don't know what's going on with the floor. Have you tried a visualizer or starting the cast higher? Is the trailer available inworld?

Link to comment
Share on other sites

7 hours ago, Wulfie Reanimator said:

Is the trailer available inworld?

Yes. I have one rezzed at Vallone/177/36/36. It's a Lusch tractor and semitrailer, with the hitch system - the trailer is one mesh prim, and can be uncoupled. Nice truck. Parked and non-physical. (It turns physical when turned on and out of neutral.) You'll see my NPCs walking through it like it's not there.

Feel free to rez test objects there. 20 minute autoreturn.

I've been in touch with the creator, and he can't figure it out either. I'm going to make a trailer like shape in Blender for comparison.

  • Thanks 1
Link to comment
Share on other sites

Several people with different ray casting testers came over and tried the truck. Ray casts on this thing have very strange behavior, like randomly failing to detect the floor and sides of the trailer. Yet you can walk on the floor and never fall through. Not something seen before by anybody involved. The creator gave me the physics model as a .dae file, and I'll look at that. Probably fixable by using solids in the physics model. Thanks, everyone.

  • Like 2
Link to comment
Share on other sites

Still don't know why the truck's physics model behaves so strangely, but built one that seems to work. The .dae file from the truck's creator, of the physics model only, needed a tiny bit of cleanup - three tiny loose triangles. After that, it can be uploaded in Surface or Solid mode and responds properly to llCastRay calls. Ray testers see the floor from both above and below, and the NPCs detect and avoid it.

Link to comment
Share on other sites

OK, got this figured out. Yet another obscure SL problem that creators sometimes need to know about.

This physics model has three tiny triangles you don't see, one on each side and one on the bottom. Those are there to make the physics model have the same bounds as the visible model. Remember that all lower LOD models and the physics model are re-centered and stretched during upload to have the same bounding box. In the visible model, this trailer has both opened and closed doors, one of which is set to transparent depending on the door position. It's done this way so that the trailer can be one prim. That makes it hitchable by linking and turnable when hitched as a single child prim. All this makes for a nice semitrailer truck that can do the things semitrailer trucks are supposed to do. The open doors project beyond the physics model, so the physics model had to be tweaked to make the sizes match.

It's a good physics model - all normals point in the correct direction, and all surfaces have thickness, except for those tiny triangles.

Firestorm detects those tiny triangles as "physics mesh too dense".

traileruploaddefaltfirestorm.thumb.png.96b227faa7cdbdb2a1538e44c07f18dd.png

Upload in "surface" mode. Default settings. If you click "Analyze", the red X disappears and upload is allowed.

But the results are not correct.These upload settings creates a physics model which seems to have random small holes in the floor as seen by llCastRay. Wulfie Reanimator and some others were able to get an image of those random holes yesterday with a ray-tracing tool. Now we can reproduce this.

The workaround is to upload in "solid" mode.

traileruploadsolidfirestorm.thumb.png.53dbf848e316bafa51d857f4cd60cb70.png

Upload in "solid" mode, simplified with detail scale 0.1, resulting in 6 convex hulls.

This works. The hulls are spread out here (that's the "explode hulls" slider) so you can see them. Top, left, right, front, and two bottom pieces, which add up to a good physics model.

Now we test with ray casts.

testofboth.thumb.png.675a7514eadeac9087cec6d021510cf7.png

On the left, the "surface" version. Simple cast ray testers in each, pointing downward. Surface version, ray cast goes right through and sees the ground. Solid version, ray cast sees the trailer floor.

The "surface" version behaves very strangely. Move the ray caster a bit and it might see the floor. That's the "random hole" effect Wulfie was able to image.

So, the workaround is to use "solid" mode when uploading physics models like this. Something is going wrong with "surface" models.

And that's why my keyframe-animated NPCs were bumping into trucks at the GTFO hub in De Campion.

 

 

 

Edited by animats
Clarify why tiny triangles needed
  • Thanks 4
Link to comment
Share on other sites

Regarding the Solid vs Surface mesh physics decomposition, I see a short blurb on the wiki that seems relevant in retrospect:

Quote

Select a decomposition method for the model. Each method is best suited to a particular type of shape, because it will return the most accurate and least costly results for models of that type:

  • Surface - best for curved, organic shapes, such as an animal body.
  • Solid - best for objects with sharp angles and a clear inside and outside, like buildings.
  • Wrap - best for very complex shapes, such as trees and branches.

I have no idea of the internal workings of these methods, but having a clearly defined interior and exterior definitely makes solid seem like the go to choice to select. It's interesting that using surface seemed to contribute to the ray cast problems.

Also, I went digging through my own jumbled notes and found this interesting blurb - which regrettably, I didn't write down the source. But I can vouch to having personally used it on several models whose physics shape was smaller than the other LODs. And it seems to hold true - at least as far as I can tell.

Quote

Two identical triangles perfectly aligned to have their normals point towards each other will cancel out on the physics mesh if you use the Solid Decomposition. This is useful for keeping the bounding box the same size as the high lod - in the case where it otherwise wouldn't be (and thus becomes warped).
 - - unknown source

Glad you got it sorted!

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

This problem has come back a few times. It's definitely associated with a disconnected vertex or triangle being used to mess with the size of the physics model. Discussed this with Chin Rey, and she gave me a door to try as a simpler test case.

raycastdoorproblem.jpg.139de62a9acd32cd5a9a960f2853d9a4.jpg

Doors. There's a loose vertex on each so as to place the object's Z axis centerline at the desired hinge point. Standard SL door trick. These behave fine for collision detection, but llCastRay calls sometimes go through without detecting them. My NPC doesn't see them, and being keyframe animated, can go right through them. Results from my ray-casting tester are inconsistent - some ray casts go through, some don't. Need to try this with one of those imaging ray cast tools.

So it's not an inside/outside problem; even this simple object shows it. A loose vertex in "surface" physics mode breaks llCastRay.

 

Edited by animats
Typo
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1493 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...