Bodies not detecting collision with my player

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Bodies not detecting collision with my player

Postby JoeJ » Fri Dec 30, 2016 3:40 pm

Hmm, would the lod switching method coming from the octree cause undesired side effects for the simulation? Probably not, but the first thing coming to my mind would be an algo like this:

Build a high resolution volume grid for the mesh.
Detect voxels inside or on the surface of the mesh.
Calculate distance field to the surface for the occupied voxels.
Use the distance for probability to randomly create a vertex in a voxel or not.
(Result would be a set of voxels loosly evenly distributed, but more vertices near the surface.)
Surface snapping.
Create voroni tetrahedronilazition.
Use a solver trying to make tetras more uniform but also keep them to the surface (allowing movement ON the surface).

Would this work, and could you reuse code from the destruction preprocessing?
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Fri Dec 30, 2016 4:55 pm

JoeJ wrote:Hmm, would the lod switching method coming from the octree cause undesired side effects for the simulation? Probably not, but the first thing coming to my mind would be an algo like

I suppose it could, but since the model is discretized anyway, one can make the case that the discrete model already has undesired behavior by the virtue of the discretization.

My guess is will be a balance that the end use will have to consider.
hopefully there will be parameters for tuning the resolution.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bodies not detecting collision with my player

Postby JoeJ » Sat Dec 31, 2016 7:36 am

This page has nice pictures showing a similar result i would expect from my idea:

https://raweb.inria.fr/rapportsactivite/RA2010/geometrica/uid15.html

Did not read how it works, but it looks very nice.
Much better than the angle and grid snapped results from the paper you linked, don't you think?
I assume the tetras would be just the dual of the mesh as it is in 2D for voroni cells to triangles.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Sat Dec 31, 2016 2:30 pm

I though of doing the approximation using voroiniid decomposition, we already have code to do that, but this is not really produces quality solution for simulation. Simulation requires simplexes.
(shape that completely defined by the it parameters, lines, triangles, tetrahedrons, circle, spheres, etc. Convex shapes aren't simplexes, that's a big problem)

One of the problem that arises when doing finite element analysis on solids is that the mesh has to be decomposed into well behaved tetrahedral mesh. This is why almost every on use Delaunay triangulation instead of voroiniid decomposition.

It is this to convert a convex polyhedron to a set of tetrahedral, you just triangulate each face and Fan the polyhedron, however this yield lots of ill formed tetrahedral.

the good thing about the algorithm I am using is the mesh is 100% Delaunay. furthermore that are only tow different size tetras. so this mesh is much more higher quality that when you get with tolls like Tetgen.

the downside is that it only works on close manifold meshes, maybe I can adapt it later for open meshes as well, and second that the mesh is an approximation, but for us that's no really a problem.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bodies not detecting collision with my player

Postby JoeJ » Sat Dec 31, 2016 3:11 pm

Julio Jerez wrote:This is why almost every on use Delaunay triangulation instead of voroiniid decomposition.


But buth are the same thing, just dual to each other, where dual means connecting poly centers through each shared edge in 2D.

Either you don't know about this, or i'm wrong with my assumption this expands to tetrahedrons in 3D :?:
Duality has many applications in geometry and graphs.

I edited the image to show:
superior-dd.jpg
superior-dd.jpg (71.05 KiB) Viewed 6436 times


They also talk about it in this paper: http://silviojemma.com/public/papers/modeling/variational%20tetrahedral%20meshing.pdf
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Sat Dec 31, 2016 4:02 pm

oh yes that seem like a good idea. something to consider after we get the fist version going.

there is still a good reason why I like the stuffing approximation, and that is that the resolution does no depend op the mesh size. it is also very fast to the point than can be use for real time simulation of fluid, specially we make a GPU version. also the adaptive resolution seem like a good feature.

on the other side the vironoid solution can probably be used for open meshes.
let us see, for now I want to get the soft body solver working on tetra solids.

also I added a function the load mesh generated by third part tool like tetgen
the use only nee to put the dat in this format

Code: Select all
20
-0.500000  0.000000  -0.500000
-0.500000  0.000000  0.500000
0.500000  0.000000  -0.500000
...
...

22
6 15 16 19
8 0 11 12
11 16 8 12
5 9 10 18
1 8 9 14


I tested with tetgen, but I was disappointed at the quality meshes I was getting from tetgen.

I am now try to get the solve back to work to see how the sphere behaves.
the I will write the linear weigh blend so that we display the user mesh no the tetra mesh.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Sat Dec 31, 2016 5:05 pm

joe if you sync you will see how the ball look like now. let us call it the newt year time square ball 8)
the one has a little overt 2800 tetras.

there are many steps I nee to do still.
1- complete the friction (easy)
2 - write the linear weight blending so that we render the visual mesh (eassy)
3 - write the potential energy function in terms of unit volume, now is too sensive to the size
4 - finish the partial derivative in the solve (important by time consuming and error prompt)
last tow imply gone back to Mathematica, which I hate to get the force equations.

once we get the model robust, go back to the tetra tool and see how to make better representation and experiment with LOD.

considering the number of tetras and that collision is brute force, performance seem very, very good. :twisted:

this mean that for loth with is less than half the calculation plus no that many links because is a surface, we do no have to worry about, we will be able to do all kind of cloth of almost any arbitrary size.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bodies not detecting collision with my player

Postby JoeJ » Sat Dec 31, 2016 6:46 pm

Really cool, that ball 8)

5 - add sticky contacts :mrgreen:
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Sun Jan 01, 2017 1:23 am

is late but now we have friction.
for now only brute force against floor.
to morrow I will add the linear blend weight, so that we render the proper mesh.
is amazing by reddening all the tringle of this mesh take longer than the solver :twisted:

I believe the reason is that, this particular mesh I have to use system memory vertex buffers,
while all other meshes are optimized which put vertex buffers in GPU memory.
that one compelling reason right there to implement the whole thing in GPU.
anyway now the ball rolls very nicely on the floor. :D
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bodies not detecting collision with my player

Postby JoeJ » Sun Jan 01, 2017 3:53 am

Yeah, could already do this: https://youtu.be/21io4lhxii0?t=9m35s
That's the ending of the game Inside.
I remember this as a really jaw dropping moment - very hard to achieve by a game nowadays.
Maybe the best game of the year.

Julio Jerez wrote:I believe the reason is that, this particular mesh I have to use system memory vertex buffers,
while all other meshes are optimized which put vertex buffers in GPU memory.
that one compelling reason right there to implement the whole thing in GPU.


Keep in mind that what you do may serve only as a template to must of us.
Probably we need to port your work to the API of choice.
Of course we can share our implementations and you can include them as examples.

I see two ways to do it:
Keep sim on CPU, upload only the hull vertices, implement blending / skinning on GPU.
Upload surrounding or all geometry, sim on GPU, download reaction forces to surroundings.

I think the first is better: No two ways communication required, constant transfer workload (surrounding geometry may a single static polygon in one frame, but dozens of bodies in the next).

The second would become attractive only if the simulation itself becomes a performance problem on CPU.


One technical detail:
AMD GPUs have some RAM (i think 256MB) that is both host and client visible (probably no cache on host).
You only need to map, copy your stuff, unmap. No need to upload.
Vulkan exposes things like that. Not sure about OpenGL, but i guess uniform buffers goes there.

I did not use this yet, but it seems very good for this purpose.
Actually i can calculate infinite bounce diffuse GI in 1.1ms, but i need a whole second to upload / download the data :? (i don't need transfer when i'm done, so don't try to improve this)

EDIT:
I'm not a experienced graphics engine developer, but there are some on the forum.
Maybe you should start a new threat with a proper topic title to discuss this.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Bodies not detecting collision with my player

Postby Sweenie » Mon Jan 02, 2017 2:55 am

Could this technique be used to simulate dented metal as well(for example a car crashing and deforming) or will it only be used for cloth and rubber-like materials?
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Bodies not detecting collision with my player

Postby JoeJ » Mon Jan 02, 2017 3:52 am

Will it be possible to attach soft bodies to dyamic rigid bodies?
Think of a soft layer under ragdoll feet.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Mon Jan 02, 2017 8:45 am

I am hoping that yes it could be stiff enough to simulate entire rigid structures.

fop the I need to complete the implicit derivative in the solver an the moment I only has the part the completed the critical to make stable, but not very rigid.

also this is not the only the only technique available for simulating finite elements, the is also the one where a stress inertial tensor is determine for each tetra and them is to a small perturbation the calculation the derivative form the there and we get a force component.
My guess this will yield more rigid structures like you mention Sweenie.

One we get a solid framework that can interact with the rest of eth engine seamless it is just a matter for adding a new collision shape class the represent a soft body style.

for now I am concerned wi the framework, that is:
solid visual system, and solid collision and at least two robust soft body models: cloth, and the rubbery deformables.

and yes joe it will be possible to attach rigid bodies to sift bodies, but no with the normal joints.
you see how the friction works already. for joints the soft joint work at the particle level by constraining them to some point on the rigid body. since the solve are force base the interaction are always tow ways, they assert forces on bodies and vise verse. that the beauty of the soft body solver is handle constraint implicitly.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Mon Jan 02, 2017 10:02 am

btw yesterday I started to write the linear bland weights function so that we render the original mesh weighted by the barycentry coordinate of each point inside a tetrahedral.

this is a trivial functionality and I already added all the support to the newton mesh for weight meshes.
to me surprised I found about half the point of the mesh were no covered by tetrahedral.

I could not imagine when that was, because it seem the sphere was 100% cover by tetras.
so after debugging and debugging and every thing checked correct, I undid everything and decide to stat over. jus to have the same thong again.

so I thought the only thing that could explained was that in fact the tetras where not covering the mesh 100%. so I change the code the use the grid generation to the more general convex hull 4d that to generate a Delaunay tetrahedralization of the point cloud. and badabin badabum that was the bug.
I was missing half the tetras by truing to generate the using a algorithmic pattern.

the mesh in fact has 4300 tetras as opposed to 2800 as before, this also explain why is was so jaggy, not the approximation is more close to the original mesh and I can calculate the linear blend weights.

the good thing is that performance doe no seem to be affected too much, so that is good so far.

the down side is that by using a algorism in pattern to make the tetras, is so fast and parallelizable that I was hoping in the future to develop a stream line version for representing small fluid volumes and model the iso suface in real time, the can make is positble to do stuff like Oil spills, small bodies of water of shallow water, rivers, lave flows, and stuff like that because the representation is a surface for a deep volume. But anyway we can revisit that later, I am sure I can figure out what tetra I was missing.


I committed the rendering of the real mesh, is you enable debug display you can see the solid mesh and how much better approximate the ball now.
I disable gravity again so that I can see how the math and until I write the function on the demo and engine side to render the weighted mesh.
one we get the going is back to the solver and the collision.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bodies not detecting collision with my player

Postby Julio Jerez » Mon Jan 02, 2017 1:07 pm

just to stimulate interes, we already have an early adopter.

https://www.youtube.com/watch?v=Aknxm7Ms_vM#t=35
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 29 guests

cron