Jump to content

Triangle physics - things you may not want to know!


Drongle McMahon
 Share

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

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

Recommended Posts

I have been trying to understand the weight calculation and behavior of triangle-based physics shapes. In doing so, I have come across some anomalies that don't seem to fit with the information currently in the wiki. Although these are experiments with simple meshes designed to answer my questions, some of the effects may be significant for people making real use of this kind of shape. So I will document some here.

Here is the case of some open-ended cylindrical meshes, such as one might well use for the walls of a real cylindrical building.  The same effects apply with fewer segments (tested down to 4) and might therefore affect many real cases.
In the wiki, it says the weights are calculated from the reciprocal of the harmonic average of the (approximate) triangle widths multiplied by the number of triangles and a constant (with the average width being clamped between 0.001 and 20m). The constant can be calculated from the criterion given as 1/20.  The width of a triangles is the shorter dimension of the smallest possible enclosing rectangle. If I am not mistaken, that is the same thing as the shortest perpendicular of the triangle.

The cylinders in the picture all have 64 idenical triangles, whose widths do not scale with vertical scaling but scale in proportion to isometric scaling in the horizontal plane.  Sure enough, the physics weights of all three, used as triangle-based physics shapes, vary as expected with scaling. That is, they don't change with vertical scaling, and they scale inversely with scaling in the horizontal plane. The pictures were made using wireframe view and physics shape display. The physics weights, shown on the right in the picture, are for dimensions 1x1x1m. They are very different. How and why?

The middle cylinder is essentially the default Blender cylinder, with smooth shading (doesn't affect physics weight, as expected) and normals pointing outward (flipping them does affect physics weight!?) and triangulated before export.  Its weight is not far off that predicted by the wiki calculation (32.65), which is within expectation as the widths are "Approximate".

The upper cylinder was made from the midlle one by choosing the alternate diagonals for the cylinder segments, then rotating the upper edge 11.25 degrees (360/32). As you can see in the picture, this gives it a set of triangles identical to those in the middle cylinder. The only difference I am aware of is the order they are specified in the collada file. In spite of that, the upper cylinder's physics weight is more than two-and-a-half times that of the middle one.

In the top two cylinders, the triangles in each cylinder are identical only if you ignore their normals, otherwise they are 32 each of mirror images. So the lower cylinder was made by rotating the top edge of the middle cylinder 5.625 degrees (360/64). Now all the triangles are identical in every respect, but the physics weight has increased nearly five-fold!

What about the behavior of these physics shapes? These were scaled up to 4x4x2 to test. The weights get lower, but remain in the same ratios. Surprisingly (to me anyway) there is a difference in behavior. For the bottom two, if you start inside, you can quite easily find places where you can walk out as if through cracks in the shape. You can't walk in from the outside.So the leakiness is in the direction of the mormals.  For the top mesh, I couldn't walk through in either direction.

I don't understand the details, but it is clear that there are unexpected effects depending on the details of specifications of these kinds of physics shapes that can have large effects on their physics weights and their behavior. Any explanations would be welcome.


cyls1.jpg

Link to comment
Share on other sites

Really interesting experiment, Drongle.  I just tried it, myself, using Maya, and my results were quite different from yours. 

My equivalents of your middle and upper cylinders resulted in physics weights that are equal to each other.   My equivalent of your bottom cylinder resulted in a physics weight precisely double that of the others. 

The numbers were 2.6, 2.6, and 5.2, respectively.  Before we try to dive into why my ratios were so different from yours, perhaps we should explore why the numbers themselves were so different.  Your base number of 32.65 for the middle cylinder is more than 12 times higher than mine.  I can't seem to find a way to make a 1x1x1M cylinder, with just 64 tris in it, come out that high.  I'm feeling like there was something in your experiment I must have missed.  What was it?

Link to comment
Share on other sites

I haven't done any testing (yet), but the lower cylinder having twice the physics weight makes sense to me. The other two cylinders have 32 planes, made out of 64 triangles, but still 32 flat planes. The lower one has twice as many.

How do the physics weights of single planes made out of various amounts of triangles compare to eachother? Worth some testing...

Link to comment
Share on other sites

My understanding, which may be entirely wrong, is that the engine always uses triangles for un-dcomposed shapes. Since I triangulated before upload, the weight calculation would have had to recognise that the quads were flat before treating them as such. Sounds hard, but right now nothing would surprise me.

For a completely flat plane, subdividing produces the expected ratios of weights, 8x per subdivision, That's 4x because the number of triangles quadruples and 2x because the "width" of the triangles halves. However, the weights seem to be lower than expected if my value of the constant multiplier is right.

The behavior of perfectly flat planes is a bit anomalous, as they rez with the perpendicular dimension set to 1.0 although the plane is zero thickness. As soon as you start pushing vertices out of the plane, it rezzes much thinner, and you have to make it 0.5m thick before you can set it to "Prim" (as far as the server is concerned - the viewer pretends it is. Maybe I should try some slated 45 degrees. That might avoid that. Hmm..

Link to comment
Share on other sites

Ah, I was reading straight from the uploader before.

I'm now looking at two of the three cylinders in-world, and the in-world results are pretty strange. 

I can't comment on the middle one yet, because SL is being stubborn at the moment, and doesn't seem to want to let me upload it.  It hangs indefinitely, every time I hit the button.  The other two are no problem, but that one just won't go.  I'll edit this post if and when it ever decides to cooperate.  In the mean time, here are the results for the upper and lower:

The upper weighs in at 5.6 for physics. The lower, in defiance of explanation, weighs just 5.0.   The more complicated shape somehow has the lower physics weight.  I've double checked, and triple checked, to make sure I did not inadvertently switch the models.  They are correct.  The lower cylinder costs 12% less than the upper cylinder.

As you predicted, the weights scale inversely with lateral size.  If I incerease size horizontally to 2x2M, the weights drop to 2.8 and 2.5.  Increasing just the vertical sizes alone has no effect.  So, that part of the math, at least, is working as expected.

My best guess as to why the lower cylinder weighs less is the approximation you mentioned in determining the intial triangle base.  Perhaps 12% is within that margin of error, and the two cylinders actually weigh the same?

As for why my numbers are six times lower than yours, I haven't a clue.

Link to comment
Share on other sites

Hmm. Very strange. We need to exchange dae files, I think. Also, are you on Aditi? We could exchange objects too.

 ETA the triangles in the bottom cylinder actually have a slightly larger "width", but only by about 0.5%. I thought that was small enough to ignore for this discussion. However, that could easily be reversed by a larger difference in the approximation.

Link to comment
Share on other sites

Here links to the three .dae files:

http://dl.dropbox.com/u/56621224/cylinderTest1.dae

http://dl.dropbox.com/u/56621224/cylinderTest2.dae

http://dl.dropbox.com/u/56621224/cylinderTest3.dae

 

I uploaded to the main grid.  If you want, I can upload them to Aditi at some point tomorrow, and drop them on you.  I'm a little too braindead to do it right now.

Link to comment
Share on other sites

Well. There's something very wierd going on here. After trying out Chosen's first file (like my middle one) and seeing the difference in physics weights, I imported it into Blender and re-exported it. Then I changed everything to be the same except the arrays of positions, normals and UV map (took out materials from Chosen's and added UV map to mine). The difference is still there.

They look exactly the same and behave the same in terms of dropping physical objects into them and being able to walk out but not in, but the physics weight, at 1x1x1, of Chosen's is 3.5 and of mine is 35.3. One other difference - in Render metadata->Show physics shapes, mine looks like the pictures I showed, with the edges of triangles visible, which is what I expect for triangle-based shapes. Chosen's stays looking like the default hull, no edges and slghtly smaller than the cylinder. It's as if the server is treating them the same as far as actual physics is concerned, but seeing them quite differently as far as cost and display is concerned (but display is the viewer!).

I will have to do more experiments tomorrow to try to find what the differences is. Then it will have to be a jira, I guess. Now I need some sllep!

Link to comment
Share on other sites

Couldn't sleep on it. I looked in detail at the triangle data. In the Maya file, and preserved when it is imported and exported from Blender, the triangles are one after the other as you gou round the cylinder, so that successive trianglesshare a side, and the winding is consistent. In the Blender file, they are not adjacent. Instead, all the triangles with edges in the top edge of the cylinder are difined first, going round, then all the triangles pointing up from the bottom edge of the cylinder. So first we get two series of alternate triangles and there is no shared edge between successive triangles in the collada file. The winding is consistent, but my impression is that it is the opposite way round to the Maya file. I hope I am wrong there because all winding should be anticlockwise, if I am not mistaken (I checked the normals - they are all pointing outwards in both). So we do have a major difference here. Obviously, it should not affect the physics weight. I'm not quite sure how to rigorously test the hypothesis that it does.

Chosen. I put the collada files in notecards and sent them to you on Aditi. Don't know how to use these dropbox things. They are versions without UV maps, but I checked that that made no difference.

Link to comment
Share on other sites

To add my two cents, size 4x4x2 (size 1x1x1), physics type prim, no analyze

___________________________

Second Life 3.4.2 (267137) Nov 19 2012 12:24:52 (Second Life Release)

You are at 206,309.0, 179,935.0, 22.9 in Mesh Sandbox 6 located at sim7027.aditi.lindenlab.com (216.82.40.144:12035)
Second Life Server 12.11.09.266804

Made with 3ds Max 2013 Design, PU 6.0, Autodesk FBX 2013.2 (Collada 1.4.1)

___________________________

Top cylinder: 0.9 (2.7)

Middle cylinder: 1.0 (3.3)

Bottom cylinder: 0.9 (3.0)

Cylinders Physics.PNG

As you can see in the picure, the top two are shown as hulls, very strange. They do not act like hulls though, I can't stand on them. Maybe this is an unrelated bug?

 

 

Link to comment
Share on other sites


Drongle McMahon wrote:

My understanding, which may be entirely wrong, is that the engine always uses triangles for un-dcomposed shapes. Since I triangulated before upload, the weight calculation would have had to recognise that the quads were flat before treating them as such. Sounds hard, but right now nothing would surprise me.

But Chosen didn't look at the triangle based physics shape. So I think what I said in my earlier post is true for hulls then. The uploader looks at the vertices and will recognise the flat quads when constructing the hull.

Link to comment
Share on other sites

That sounds to me like the structure (order) of the exported data results in an inefficiencient interpretation in the importer. Maybe an automatic recognition of triangle strips ?

Possibly the Blender exporter does a bad job here. Which Blender version did you use for your tests ?

Link to comment
Share on other sites

Gaia. I was using 2.64. I suppose some (can't think who :-)) might say it is the fault of the exporter, but think that would be quite unfair. They are both specifying exactly the same triangles, and that is all that should affect the triangle-based physics weight. So it's surely a problem with the weight calculator. Also, it's not the exporter itself, but the internal structure of the cylinder created in Blender, because the Maya one still has the same arrangement and weight after importing into Blender and re-exporting.

However, given the response to a previous physics weight bug I reported, the chances of getting it changed may be very small. In that case, it may be that some changes to the exporter might remedy it (or make Blender export equally wrong?). I think we should try to arrive at a clear understanding before contemplating that though.

I checked the winding of the Blender export, and it is anticlockwise if you are looking from the side the normal points out of. I think that is correct. I should recheck the Maya one.

I am doing some more experiments with a 4-sided cylinder, easier to edit by hand, to see if I can find out the exact causes. Alreadsy found another unrelated problem - on its own it's pw is 0.6, with two far apart each the same size it's 6.2 !!! Arrrggghhh.

Link to comment
Share on other sites

Oh yes - that's certainly the case with hulls.

Your picture with the hull physics shape display when it should be triangles, and behaves as triangle, is exactly what I see with the Maya-originated cylinder. I guess thast means Maya and 3D are doing the same thing, which is not surprising. Is there finally a justification for people who can afford these? Is it an anti-Blender conspiracy? :smileysurprised:

Link to comment
Share on other sites

A side note - I reversed the winding of the triangles. There was a small change in weight, which I had seen before on reversing the normals (35.3 -> 34.8). The visible mesh was inside-out. So the winding overrides the direction of the normals. So I reversed all the normals (changing sign of all components except zeros). It was still inside out. So it's not just inverting the normal, it's actially deciding it's direction. That seems odd to me - anything I did wrong?

Anyway, that means the Blender and Maya originated cylinders both had he same winding, and winding can't explain it.

I also changed the order triangles and vertices to match the Maya order as far as I coulkd .... no effect! I am stumped. I don't know what to test next. I think I'll try to bring the cylinders to the content creation group today and see hat Nyx can make of them.

Link to comment
Share on other sites


Drongle McMahon wrote:

 

Your picture with the hull physics shape display when it should be triangles, and behaves as triangle, is exactly what I see with the Maya-originated cylinder. I guess thast means Maya and 3D are doing the same thing, which is not surprising.

That's what I figured.

Maya and 3ds doing the same is not all that obvious to me though. Although they are owned by the same company, they were and still are developed seperately so not even the exporter will be exactly the same. I'm sure since Autodesk decided to own everything there's a reasonable amount of exchange between the two, but I don't expect the two to blend into one program, at least not any time soon.

Either way, my 3ds figures were different from Chosen's Maya figures.


 Is there finally a justification for people who can afford these? Is it an anti-Blender conspiracy? :smileysurprised:

There always was and you just found one of the main reasons....

 

 

Maya and 3ds will always be a step ahead and with issues like these there's no need for forums like these to find them and fix them. (And then having to wait 3 updates to have it fixed properly). And ofcourse it's a conspiracy. 69.4% the devs on Blender are employed by Autodesk to screw things up, didn't you know that?

Link to comment
Share on other sites

You will have to forgive me here, I am new at this whole mesh modeling thing and probably have no clue what I am talking about.  May I ask what viewer you both were using when importing to SL?  It is probably just me, but I am not sure all viewers are created equal when it comes to uploads and calculations I can't prove it...just an odd feeling I have when doing some projects using different mesh creators and different viewers to upload. 

Link to comment
Share on other sites

I am only using the (latest release) official viewer. The viewer can certainly have significant effects on the download and Analyzed physics weights because some tpvs might use different libraries for generating LOD meshes and for convex decomposition. I guess they might also have differences affecting how the numbers presented for triangle (not Analyzed) physics shapes. However, the actual weights are calculated by the server.

Link to comment
Share on other sites


Drongle McMahon wrote:

And there was me thinking it must be the SL developers! :matte-motes-smile:

You're quite unfair to the Blender guys for speed of response though.

I just said Autodesk wants to own everything, where's your conspiracy mind? 47.8% of LL employees are paid by Autodesk to screw up Blender.

I'm unfair? I'm sticking my neck out by telling you this, since 56.2% of my paycheck comes from Autodesk. Shhh!

@Morgaine, I posted my stats in an earlier post (for the upload I used the latest viewer)

Link to comment
Share on other sites

Did some more experiments. Not there yet, but by altering the order of triangles and vertices within triangles, starting with the BLender-exported file, I have got versions that have weights of 35.3, 17.1 or 14.4. I think that's enough to show that the orders matter, which doesn't make any sense to me when they all have the identical triangles.

Link to comment
Share on other sites

OK. Finally managed to manually edit the ex-Blender file to make it have physics weight 3.5. I find this close to incredible, but it seems to depend only on the precise order of triangles and vertices within the file. The vertices are in completely different order and I only edited the order of the indexes in the <polylist>, where there are three per triangle. You have to have all these three steps the same as in the ex-Maya file. The first two steps only bring it down from 35 to about 17 then 15. Adding the final step makes it 3.5...

1. All the triangles must appear in the sequence so that successive triangles share an edge, and with a precise order of vertices.

2. Successive triangles must wind round the cylinder in the right direction.

3. The sequence of triangles must start at the right point on the cylinder circumference.

Tomorrow, I will look at small departures from these rules to see how fast the weight goes up when they are broken.

Can it really be a coincidence that, out of the myriad possible arrangements of the data, the Autodesk software just happens to produce the optimum one? Or could it be that the weight calculator accidentally makes implicit assumptions, which don't appear in the wiki, because it was developed with the outputs of that software? Or could it even be .... no, surely not!

 

Link to comment
Share on other sites


Drongle McMahon wrote:

 

Can it really be a coincidence that, out of the myriad possible arrangements of the data, the Autodesk software just happens to produce the optimum one? Or could it be that the weight calculator accidentally makes implicit assumptions, which don't appear in the wiki, because it was developed with the outputs of that software?

The fact that Autodesk has a good implementation of the collada scheme is no surprise, since they were involved from the beginning in developing it. What does surprise me, is SL making distinctions between different collada files which contain the same geometry. Like you say, one would think since SL uses its own format, the weights would be the same.

Maybe it's easier for the server to calculate collisions when the triangles are adjacent. No idea, but if that's the case, the wiki sure isn't complete. I think all of this can only be answered by someone who knows how the internal format is written and/or someone who knows how the physics engine works exactly.

On the upside, you now know how to reduce the weight, so the people who made the dae exporter for Blender can rewrite it. This means the issue doesn't neccecarily needs to be fixed by LL.

btw I now finally understand your "obsession" with the hulls, a feature I have never really used myself. I always thought the triangle based shapes were much more convenient. No wonder you didn't, with a physics weight 10 times bigger.

Good luck with furter testing, the Blender community will be greatful and maybe you can call yourself "Mr. Physics"  pretty soon.

If I can find some time, I might have a look if the vertex order in 3ds max is the same order in the exported dae equivalent. Afterall, it might just be a bad choice by the Blender devs (drawing the defaul cylinder top first bottom second) rather than a bugged exporter.

Link to comment
Share on other sites

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