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 4159 days.

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

Recommended Posts

It is certainly the Blender internals, not the exporter, because importing the Maya version and re-exporting it keeps the low weight structure. I don't think "good" and "bad" come into it. The Blender collada is perfectly accurate. There is nothing in the collada specification that would imply the need for certain triangle layouts (as far as I recall). Of course, there is a whole section of collada dealing with physics which is not used at all by SL. Instead, SL uses the visual scene mechanism to specify the physics mesh. I suppose there could be something resulting from that that wouldc explain these effects. I don't know enough about that. I do wish we could see the weight calculation code, but it might involve bits of Havok, which would preclude its release even if they did let use see some server code snippets.

Link to comment
Share on other sites


Drongle McMahon wrote:

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.

Hi, Drongle;

Ok... so the following questions also need to be answered :)

 

  • What is "the precise order of the vertices" ?
  • What is "the right direction" ?
  • What is the "right point on the cylinder circumference" ?

 

Also can you tell more details please ?  Ideally you should provide:

 

  1. a blend file containing an example with the smallest possible number of triangles to show the problem.
  2. The exported Collada-file from Blender which creates the high physics costs.
  3. your modified Collada-file which creates the optimized physics costs.

 

You can open a report in the Blender tracker or provide the information elsewhere and tell me. Then i will do the report for you.

Link to comment
Share on other sites

More or less what I am aiming at, although I will add lots of intermediate files to see how big are the effects of various extents of deviation from the optimum. I think I should be able to get it down to a 12-sided cylinder. Anything less and it runs into the 0.5 minimum physics weight. It may have to be 16.

I might write something in R to generate the files. Too many hours of painstaking manual editing is making my head hurt!

As far as being able to use the information to optimise the exporter is concerned, I'm not sure how well the lessons from cylinders will be transferrable to more general cases. I guess I will have to look at other cases if ?I can maintain my interest. Or it may be betterv to wait for a response from LL to see whether they can mitigate the problem.

 

Link to comment
Share on other sites

Here is some more news from doing a hundred or so uploads after automating the editing. All for a default sixteen sided cylinder at 0.5x0.5x0.5. Triangle and vertex index orders in the <polylist>  were manipulated in R and pasted into a file so that everything else was fixed..

It turns out that I was over-interpreting an incomplete set of data. As I had not tesed all combinations, I was attributing differences to the wrong source in some cases. With more combinations it becomes clear the direction around the cylinder the triangles are odered is not important. If the triangles are all sequentialy sharing edges, then the overwhelming differences are dependent on where they start .. where the seam is, more or less. This accounts for variation from 2.4 to 19.0 when there are no faces perpendicular to an axis.

Low weights (3.5) can be found with the non-adjacent triangle sequence generated by Blender with some sequences of triangles, but this arrangement can still give weights up to 114.5. That number can also happen with all triangles sequentially adjacent, but with the order of vertices within the triangles different from the optimum. It never seems to get higher even when combining effects that give that weight individually. So there may be some sort of threshold that makes that the maximum.

So far the range of weights with just this geometry has been 2.4 to 114.5. That's nearly fifty-fold variation. There are still too many variables to look at. For example, tilting the model before exporting  can also change the weight. Leaving it as quads so that the uploader triangulted it instead of Blender gave a lower weights, but that was only with one orientation. Rotating it might produce the opposite effect.

 

Link to comment
Share on other sites

Note - you can observe a substantial part of this variation simply by rotating the cylinder about the Z axis in Blender before exporting it. That doesn't seem to get to the lowest weights. as that requires changing the triangle and vertex index oders in the collada file, but it does incluse a range at least from 114.5 to 8.1 for the 16-sided 0.5x0.5x0.5 cylinder. Perhaps someone with Maya and/or 3DS could see whether rotating a cylinder like this (by 22.5 degree increments) changes the triangle-based physics weight of the exported mesh?

Link to comment
Share on other sites

I get lower figures than you do, but you are certainly on to something.

(16 sided, .5x.5x.5m)

 

0 degrees: 3.2

22.5 degrees counterclockwise: 1.3

45: 6.6

67.5: 7.2

90: 19.2

112.5: 6.2

135: 13.7

157.5: 6.1

180: 3.7

202.5: 13.4

225: 12.5

247.5: 1.3

270: 20.8

292.5: 7.9

315: 3.1

337.5: 3.8

Vertex order in 3ds max is bottom row first, top row last, counting counterclockwise with vertex 1 on the highest x value of the cylinder. I didn't check the dae file, so that order might be different.

Cylinder.PNG

 

Link to comment
Share on other sites

Thanks. Important to know that it can affect other sources too. That's like the Maya vertyex ordering. Blender is different - top, bottom, top, bottom, etc. However, it's not the order of vertices in the vertex list that matters. It's the order they are referenced in the <polylist> (or, presumably <triangles> - I haven't tried that yet). Both the order of triangles and the order of vertices in each triangle affect thye weight.

Intersting results with flipping normals, manuall inverting them or omitting them altogether. It does make a difference, but seems to be the vertex winding that has the effect, not the normals theselves.

 

Link to comment
Share on other sites

The wiki says the triangle width is the smaller side of the tightest rectangle you can get the triangle into. The fact that it is a rectangle certainy suggests to me that it is in the same plane as the rectangle and thus that the width would not depend on the orientation of the triangle in 3D space. However, as I said, nothing would surprise me. The calculation of the harmonic average is such that if all the triangles have the same widthm then the harmonic average width would be the same as that width (taking account of the fact that there is an error in the equation of the harmonic average in the wiki).

Meanwhile, some better news...

I made a generator that randomised the order of the triangles. From looking at a number of these, I noticed that two which had the same triangle first also had the same weight. So I tested the hypothesis that the first triangle in the list was sufficient to determine the weight - and it is! As long as I kept the first triangle the same, randomising the order of the rest had no effect on the weight (at least for 12 tested orders). The order of vertices in that triangle still has an effect, but it's not just which vertex is first. Testing an extra detached triangle inserted as the first bin the list showed that changing its orientation could change the weight.

This is a huge simplification, which should make it much easier to discvover the cause in the calculation code. So now I am ready to make a jira. Also, I think it offers some hope of devising a work-around if the developers choose not to correct the problem, although it's still not going to be easy.

 

Link to comment
Share on other sites

How to observe this effect in Blender 2.64. Starting from an empty scene, first make a plane, triangulate it, delete one of the triangle ans scale to 0.25x. This horizontal triangle will appear as the first triangle in the list in the <polylist> tag in the collada file. Changing this will have the largest effect on the triangle-based physics weights.

Now add enough of your chosen geometry to give you a weight well above 0.5 (the minimum limit) so that you can see the changes. Export (no uv map needed - it makes no difference) and import using default LODs, choosing "Highest" for the physics shape and NOT clicking Analyze (so you get a triangle-based weight. Rez the imported mesh and switch to physics shape type "Prim" on the features tab of the edit dialog. Use the "More Info" link to see the weight details and note the physics weight.

Now you can test what happens if you rotate and size the isolated triangle. An extreme example is a twice subdivided cube 1x1x1 with the triangle, short side 0.5, hovering 1m above, rotated 90 degrees around Y. This has a weight of 230.5. If you then rotate the triangle 180 degrees around Z, the weight drops to 21.4. Where is the sense in that? The most extreme high weights seem to happen with the triangle perpendicular to one of the axes, and they are very sensitive to very small deviations (eg 0.0005 m) out of the plane.

This technique might provide a way to mitigate the high triangle physics weights that happen unexpectedly from time to time, although it may take some experimentation to know what the best triangle is in each case. Hopefully the strange effects can be eliminated by changes to the code, making this uneccessary.

Of course, nobody would actually use a subdivided cube for a triangle-based shape. I used it here to get larger numbers so that I could see smaller variations. But the same effects happen with realistic shapes, like the cylinders I was using above. So using these examples should not be seen as reducing the importance of the effect.

Although the first triangle does seem to have the largest effect, it isn't the only thing that matters, For example, flipping the normals in the rest of the model can have quite large effects.

  • Like 1
Link to comment
Share on other sites

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