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: 10339
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: 10339
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: 10339
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: 2
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: 10339
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

rw1445
Posts: 4
Joined: 05 May 2020, 15:28

Re: Do heightfields work with the Newton engine?

Post by rw1445 »

Hi

I am using height fields and getting really weird bugs for heights fields in specific grid sizes and not others. Using Newton physics and version 4.00 of coppeliasim Edu

I am trying to see the affect of grid size on my robots ability to traverse a height grid of random heights. At certain grid sizes the robot fall through and at others it does not.

If you need my code I can upload it but I think the videos in this folder show the problem reasonably well.
https://drive.google.com/file/d/1GlPPLd ... sp=sharing

Thanks,

Rob

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

Re: Do heightfields work with the Newton engine?

Post by coppelia »

Hello Rob,

yes, that looks wrong. To speed-up things, could you send us (or post) the incriminated scene?

cheers

Post Reply