NTBI

SVT2/SPT2 Guide to Mesh Roads

Our most recent generations of vehicle scripts, SVT2 and SPT2, utilize raycasting to simulate suspension and detect wheel contact. Unfortunately, some mesh roads are designed in such a way that raycasting is impossible. This page demonstrates why that is, and how to avoid it.

1
What is raycasting?

Raycasting is one of three ways to detect objects in LSL, the scripting language for Second Life. They differ slightly:

More specifically, raycasting works by sending the beam (the "ray") from the start to the end point, and reports the specific locations and objects where it intersects with a physics shape. Raycasting is very expandable and useful, but for our purposes, we only use it to detect a single non-physical object (or land). Each wheel hub is controlled independently for the suspension system, so there are four raycasts on the vehicle. When a certain number of these raycasts detect no collisions (two rear in SVT2 and all four in SPT2) the vehicle is considered airborne on the drive axle, so it cannot apply power. (SPT2 implements raycasting for roof and side collision detection as well, but that's not critical to the script operation.)

Naturally, raycasting is the ideal solution for wheels, because it is very fast and can detect the distance between the origin and the hit point (critical for our suspension system). However, it has some problems.

2
Why does it screw up on mesh roads?

Raycasting is designed to work most efficiently on prims. When it tries to detect collisions on mesh objects, it has problems.

Certain mesh objects are designed such that their physics shapes are extremely thin. At a certain point, the raycasting system simply passes through them without noticing. This is particularly noticeable when driving on a mesh object with a wedge-shaped physics shape (the bridges in Second Norway exhibit this problem) - at a certain point along the bridge near the center, SVT2/SPT2 vehicles suddenly lose traction and their wheels appear to fall through the road.

What's strange is that the physics system handles these physics shapes relatively correctly. You can still collide with them, and vehicles that do not rely on raycasting can drive over them just fine. This is why new NTBI vehicles are called out for not being able to drive on mesh roads.

Most importantly, though, is that not all mesh roads do this. Some are designed with a sufficient physics shape (we recommend 0.25m thickness). We developed a simple raycasting test tool and used it to perform some tests on popular mesh roads; the results are at the bottom of the page.

3
Then why did you morons use raycasting anyway?

Simple - airborne detection.

Many cars do not bother, but SVT2 and SPT2 both have special "airborne modes" where power is cut. In SPT2's case, dynamics and vehicle properties are also changed mid-air, and the rear tires will spin in the air. Without this mode, the vehicles would still be able to be controlled while in the air, and would appear to continue driving even without a road.

4
Whatever, is there a workaround?

For SVT2, yes. Go to Config -> Rename and type in !!RCOVERRIDE - this will disable raycasting, but your vehicle may act erratically in the air.

Unfortunately, SPT2 has been tweaked and enhanced so often that the "bedrock" of raycasting support has snuck into almost every aspect of the vehicle's dynamics. It is technically possible to disable raycasting, but doing so would so degrade the vehicle's driving experience that we chose not to make it a public option.

5
Test Results

The following table demonstrates the results we obtained when testing a variety of mesh roads available on the Marketplace.

NOTICE: Inclusion on this list is not an endorsement. NTBI is not compensated for inclusion on this list, nor does it approve of these particular manufacturers. This list is not an indication of quality, it only shows whether a road is capable of being detected by raycasting. This list is not conclusive.

Working Not Working
NTBI Wiki

PUBLIC WIKI

© 2012-2024 NTBI Group - All Rights Reserved

PRIVACY POLICY - CONTACT US - OUR LOCATIONS - SERVER STATUS
You are not logged in. Personalized features may be unavailable.

LOG IN - HOW DO I GET AN ACCOUNT?