Jump to content

Physics Jitter on SphereCollider


SpiderPig
 Share

Go to solution Solved by SpiderPig,

Recommended Posts

Also it seems with sphere colliders the cubes are not actually colliding with the surface.  For primitive shapes, such as cubes and spheres, is newton actually using the mesh to test collision?  Or is it calculating the surface of the sphere with it's position and radius?  That might explain why there is a gap.

PhysicsOffset.thumb.png.19cd8d4961bb48cffd4bd9b6834b2b12.png

Link to comment
Share on other sites

  • Solution

So it appears that just a sphere collider will create the above issues.  Using a sphere mesh collider works best.  There is no gap between the surface(other than the obvious gap as the surface curves) and the jitter is gone completely.

auto sphere = CreateSphere(world, 25.0f);
auto collider = CreateMeshCollider(sphere->lods[0]->meshes[0]);
sphere->SetCollider(collider);

@Josh does all this sound like a bug to you or is it just the way of sphere collisions?

Link to comment
Share on other sites

  • SpiderPig changed the title to Physics Jitter on SphereCollider

A small example.

#include "UltraEngine.h"
#include "ComponentSystem.h"
using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1440, 900, displays[0]);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();

    auto camera = CreateCamera(world);
    camera->Move(0, 26, -3);
    camera->SetClearColor(1, 0, 0);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 35, 35);

    auto sphere = CreateSphere(world, 25.0f);

    auto box = CreateBox(world);
    box->SetMass(1.0f);
    box->SetPosition(-0.5f, 26.0f, 0.0f, true);

    while (window->KeyHit(KEY_ESCAPE) == false && window->Closed() == false)
    {

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

I looks like is has trouble coming to rest, since the surface is not flat. I suppose no matter which way the cube falls, it's never going to be on a flat surface.

In any case, I will check this out. 

You might also check out the cube sphere, as this will provide a more even distribution of polygons:
https://www.ultraengine.com/learn/CreateCubeSphere?lang=cpp

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...