Jump to content

Airplane script is affected by prim placement: Why?


Rolig Loon
 Share

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

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

Recommended Posts

This falls into the category of annoying mysteries.  I have had very little to do with scripting vehicles, but decided to create a simple one-person helicopter just to get a feel for the parameters. It works, and it's kinda cute, but I discovered that as soon as I add a single small prim (an unscripted light bulb) to its rear fin, the vehicle's angular motor becomes very sluggish.  It's like trying to turn in stiff molasses. However, if I move the same prim toward the vehicle's center of mass, without making any change in the script, the vehicle's angular motor responds quite quickly.  So, what am I overlooking?

Link to comment
Share on other sites

When you add prims to the build you change the moment of inertia. A high moment of inertia requires a larger torque to turn the object. The issue is that the moment of inertia is additive. You can find the total moment of inertia around a given axis by adding up the moments for each small mass. The moment of inertia for a small mass is proportional to the square of the distance around the pivot. So when you move a small prim away from the center of the build it can have a big impact on the moment of inertia of the object around one of the axes.

Link to comment
Share on other sites

Yes, that certainly makes sense in the context of RL physics. I'm a little surprised to see that SL physics is so sensitive to moment of inertia, though.  The whole aircraft is no more than 3m from wingtip to wingtip, or prow to stern, and the center is necessarily hollow, because you have to have somewhere to sit.  Its moment of inertia, therefore, is fairly high.  This is really a design question, then.  Other than trying to cram more of an aircraft's mass around its center of gravity, is there a scripted approach to compensate for the loss of angular motor repsonse?

Link to comment
Share on other sites

I personally think that the SL physics engine is relatively good. In this case what matters is the percent change in the moment of inertia. Even if it is a small object a change in the position can result in a relatively large change in the moment. If you want to calculate your own moment of inertia you have two options. In either case you need to first calculate the center of mass. You will have to calculate a moment about each priniciple axis which you apply a torque or angular impulse.  Then you loop through each prim and add its contribution to the moment of inertia around the respective axis.

The more accurate way is to use the parallel axis theorem. This is made more difficult when you consider that the rotation of the prim needs to be considered when calculating its moment of inertia around a given axis. The other, less accurate way is to just treat each prim as a point mass. The second method is much easier to do. I have done it with small objects, and it works okay but not great.

 

Link to comment
Share on other sites

Yes, those are the same options that I'd have in RL, so it makes sense that they would apply in SL too. Calculating moment of inertia would be a nasty job, especially since you also have to consider the mass and placement of the avatar pilot.  I have just been experimenting with decreasing the VEHICLE_ANGULAR_MOTOR_TIMESCALE and increasing the magnitude of the X component of the angular motor direction vector. That seems to help a bit, although it's essentially just using a bigger hammer.

Thanks.  Your suggestions are reassuring, and this is a nice (if silly) learning exercise.

Link to comment
Share on other sites

  • 7 years later...

Can you set the prim in question to not have a physics shape at all?

It's been a while but I seem to remember that if it's not the root prim you can set it phantom.  I'm on a tablet and not logged in to check so I forget how to do it in scripts, but in the editor one can edit a link and choose between prim, convex hull, and none.  I'd give that a try (set the trouble prim to none for physics shape)....and if it helps look into how to set these things from a script if you need it.

 

Do phantom prim stil apply mass?

Edited by Credo Rolland
  • Confused 1
Link to comment
Share on other sites

8 minutes ago, Credo Rolland said:

Can you set the prim in question to not have a physics shape at all?

no you can't and this thread is pretty old - nowadays you would add just a mesh lightbulb that has no physics model at all - prims will always have physics or not depending on the whole linkset you cannot turn it off for a single prim...

Link to comment
Share on other sites

I just got a dozen notifications pop up on it as if it's an active question.  Either way, old threads never really die as people do web searches looking for answers every day, so no biggie.  If it were a problem they'd auto lock inactive threads after some amount of time.  No?

 

I'm pretty sure I found ways to do it but I can't log in to get the details right now....I'll have to log in to double check, but yes....I have mixed mesh/prim builds with phantom prim parts on it.  I.E. rockets with bog standard SL cones and animated textures to simulate plazma.....the rest of the ship is bound to aa simple physics mesh but these were tacked on later...and you can fly right through the cones.  I wouldn't know about an all prim build as I've not tried that, but I don't see why it would not work since all the child links give you a choice between convex hull, prim, or none.

 

  • Confused 1
Link to comment
Share on other sites

1 hour ago, Fionalein said:

no you can't and this thread is pretty old - nowadays you would add just a mesh lightbulb that has no physics model at all - prims will always have physics or not depending on the whole linkset you cannot turn it off for a single prim...

Theresa Tennyson sighs.

Create a linkset. Then select "Edit linked", pick the prim you want to change, go to the "Features" tab and set the "Physics Shape Type" to "None." It works with regular prims, and we've been able to do that for years.

Link to comment
Share on other sites

1 hour ago, Credo Rolland said:

If it were a problem they'd auto lock inactive threads after some amount of time.  No?

No, that's not the way it works.  Threads get locked if they contain offensive language or break the forum rules in other ways, but not because they are old.  As a result, people doing Google searches can stumble into extinct threads and mistakenly assume that the information in them is current.  We all know that's often untrue.  SL changes.  New features are added, old bugs resolved, new bugs introduced.   Old fixes may or may not work six months later.  Following the advice in ancient threads is risky.

As far as the "phantom" business is concerned, the answer is NO, you cannot choose to make only one link in a linkset phantom.  It's all or nothing.  However, as you have discovered, you can change the physics shape type of any individual link (except the root) to physics shape type None.  When you do that, the physics engine will ignore collisions with that link.,  It is effectively the same thing as making that link phantom, although it works a little differently under the hood.   If you want to do that by script, use llSetLinkPrimitiveParams with the parameter PRIM_PHYSICS_SHAPE_TYPE.

Edited by Rolig Loon
  • Thanks 1
Link to comment
Share on other sites

9 hours ago, Fionalein said:

nowadays you would add just a mesh lightbulb that has no physics model at all - prims will always have physics or not depending on the whole linkset you cannot turn it off for a single prim...

You can't make a mesh model without a physics model at all. Everything on SL has to have a physics shape, even if it is ignored by the physics engine. And you can absolutely turn off the physics shape of any individual prims in a linkset. Only the root has to have a shape.

See: Two default box prims linked together, link 2 set to no physics shape.

7e25078958.png

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

OK, to me, even though it might be different 'under the hood'....if something doesn't have a physics bounding box, add mass, or accept collisions, and objects can pass through it, it's in a sense 'phantom'.

 

I'll stop stinking up the place now.  One day I'll learn my lesson about forums and social media (and doubly so when using a small portable device).  BTW, I just now got another dozen pop-up notifications telling me about 'new threads' and 'new replies' that are not so 'new'.  It's much easier to sort out on my PC that it's ancient content than it was on my little android tablet.

Link to comment
Share on other sites

1 hour ago, Credo Rolland said:

OK, to me, even though it might be different 'under the hood'....if something doesn't have a physics bounding box, add mass, or accept collisions, and objects can pass through it, it's in a sense 'phantom'.

you are right. Its just that the way the SL physics engine works then is 3 levels of phantom when dealing with linksets

1) Phantom linkset with a physics shape for the entire linkset

2) Phantom  linkset with all prims, other than the root prim, without a physics shape

3) Phantom linkset with all prims, other than the root prim, without a physics shape, and where the root prim has a physics shape and has been set to phantom

can seem kinda nit picky this. But this is a scripting forum so is a tendency to be more precise than in a general conversational forum

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, Wulfie Reanimator said:

You can't make a mesh model without a physics model at all. Everything on SL has to have a physics shape, even if it is ignored by the physics engine. And you can absolutely turn off the physics shape of any individual prims in a linkset. Only the root has to have a shape.

 

Yes, I'd discovered that SL will always generate some sort of physics shape when you upload a mesh that doesn't have your own included.

 

The nice thing is that if you end up in a situation where the physics cost is way to high for a mesh object you can't control (re work-upload), one can use a simple box, or upload a new transparent physics shape and make it the 'root' of the linkset, then set the costly mesh to 'none' once it becomes a 'child' link instead of the root.

 

The trick has saved me many a LI or other server costs over the years, as well as time trying to rework things that I can't always control.

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2001 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...