Page 1 of 1

Do heightfields work with the Newton engine?

Posted: 21 Aug 2019, 11:02
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

Re: Do heightfields work with the Newton engine?

Posted: 21 Aug 2019, 15:43
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

Re: Do heightfields work with the Newton engine?

Posted: 28 Aug 2019, 13:07
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

Re: Do heightfields work with the Newton engine?

Posted: 29 Aug 2019, 11:41
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

Re: Do heightfields work with the Newton engine?

Posted: 29 Aug 2019, 13:10
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

Re: Do heightfields work with the Newton engine?

Posted: 02 Sep 2019, 10:09
by SimonBirrell
Hi!

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

Best,

Simon

Re: Do heightfields work with the Newton engine?

Posted: 19 Nov 2019, 11:25
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

Re: Do heightfields work with the Newton engine?

Posted: 21 Nov 2019, 06:25
by coppelia
Hello Robert,

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

Cheers

Re: Do heightfields work with the Newton engine?

Posted: 10 Mar 2021, 15:56
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

Re: Do heightfields work with the Newton engine?

Posted: 12 Mar 2021, 13:15
by coppelia
Hello Rob,

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

cheers