Do heightfields work with the Newton engine?

Typically: "How do I... ", "How can I... " questions
Post Reply
SimonBirrell
Posts: 8
Joined: 05 Apr 2019, 10:21

Do heightfields work with the Newton engine?

Post by SimonBirrell »

Hi,

If I start with a new scene, import a heightfield from a BMP and then add a dynamic sphere above it, then the sphere falls, bounces and rolls around as you would expect. This is with Bullet 2.78 selected as the physics engine.

Now switch to Newton. The ball falls right through the heightfield.

You can see the problem in the scene at the following link: https://www.icloud.com/iclouddrive/0euq ... ield-test

Is there any way to make heightfields work with Newton?

Simon

coppelia
Site Admin
Posts: 7838
Joined: 14 Dec 2012, 00:25

Re: Do heightfields work with the Newton engine?

Post by coppelia »

Hello Simon,

looking at the source code for the Newton dynamics plugin, it seems that heightfields are not yet (or not fully, or wrongly) implemented, unfortunately.
See file CollShapeDyn_newton.cpp, TODO_NEWTON_X1.

Cheers

coppelia
Site Admin
Posts: 7838
Joined: 14 Dec 2012, 00:25

Re: Do heightfields work with the Newton engine?

Post by coppelia »

Hello again,

you can find the fixed binaries here:
Following is the fix:

Code: Select all

                case sim_pure_primitive_heightfield:
                {
                    int xCnt,yCnt; // height values along x or y
                    float minH,maxH; // min and max heights (relative to frame)
                    // Heightfield x and y size is: s(0) and s(1)
                    // Heightfield pad x-size is: s(0)/(float(xCnt-1))
                    // Heightfield pad y-size is: s(1)/(float(yCnt-1))
                    const float* hData=_simGetHeightfieldData(geomInfo,&xCnt,&yCnt,&minH,&maxH);
                    // hData contains xCnt*yCnt heights in following order: x0y0, x1,y0, ..., xn,y0,x0y1,x1y1, ...
                    _newtonHeightfieldData.resize(xCnt*yCnt);
                    for (int i=0;i<xCnt;i++)
                    {
                        for (int j=0;j<yCnt;j++)
                            _newtonHeightfieldData[(xCnt-1-i)+xCnt*j]=hData[i+xCnt*j];
                    }
                    C3X3Matrix rot1;
                    rot1.buildXRotation(-piValue/2.0f);
                    C3X3Matrix rot2;
                    rot2.buildZRotation(piValue);
                    C7Vector ilif;
                    ilif.setIdentity();
                    ilif.Q=rot2.getQuaternion()*ilif.Q;
                    ilif.Q=rot1.getQuaternion()*ilif.Q;
                    ilif.X+=C3Vector(s(0),0.0f,s(1))*0.5f;
                    ilif.inverse();
                    dMatrix invMatrix (GetDMatrixFromVrepTransformation(ilif));
                    char* attributeMap=new char[xCnt*yCnt];
                    for (int i=0;i<xCnt*yCnt;i++)
                        attributeMap[i]=0;
                    _shape = NewtonCreateHeightFieldCollision(world,xCnt,yCnt,1,0,&_newtonHeightfieldData[0],attributeMap,1.0f,s(0)/(float(xCnt-1)),0);
                    NewtonCollisionSetMatrix(_shape,&invMatrix[0][0]);
                    break;
                }
Cheers

SimonBirrell
Posts: 8
Joined: 05 Apr 2019, 10:21

Re: Do heightfields work with the Newton engine?

Post by SimonBirrell »

Hi,

I downloaded the binary (for Ubuntu 16.04), overwrote the old one and added execution permission. Now when I select Newton as the engine I get the following message:

The physics engine currently selected is not supported (you might be missing a required plugin). Simulation will not run correctly.

Any idea? Thanks!

Simon

coppelia
Site Admin
Posts: 7838
Joined: 14 Dec 2012, 00:25

Re: Do heightfields work with the Newton engine?

Post by coppelia »

Hi Simon,

that's strange, I just tested on a clean installation, and the plugin loads fine...
What does the console say?

Cheers

SimonBirrell
Posts: 8
Joined: 05 Apr 2019, 10:21

Re: Do heightfields work with the Newton engine?

Post by SimonBirrell »

Hi!

It works, thanks! I was still on 3.6.1. Upgrading fixed the issue.

Best,

Simon

RobertPastor
Posts: 1
Joined: 10 Nov 2019, 16:33

Re: Do heightfields work with the Newton engine?

Post by RobertPastor »

Hello,

I ran into the same issue. Heightfields ignoring collisions.
The links to the fixed binaries no longer works.
Can you please upload them again?

Robert

coppelia
Site Admin
Posts: 7838
Joined: 14 Dec 2012, 00:25

Re: Do heightfields work with the Newton engine?

Post by coppelia »

Hello Robert,

please download the beta version of CoppeliaSim, or wait until CoppeliaSim is released next week.

Cheers

Post Reply