Search Unity

[custom physics]Simplifed custom collision detection to only use closest points[GJK with no EPA].

Discussion in 'DOTS Physics' started by Mr-Mechanical, Dec 8, 2019.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    Hello,

    I am using Unity Physics as a collision solution for my custom physics engine, however, the collision scheme only requires the closest points of the hulls without any other additional information. Therefore, I think I would like to disable EPA, since I only need closest points. Also, I don't need any contact jacobians(can be disabled with flag) or the solver itself. Perhaps an option here is to rework the narrowphase system myself and delete the scheduling code for the solver and jacobian related tasks. I am looking for ideas.

    Thanks a lot, feedback is considerably helpful and appreciated.
     
  2. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    Can I safely comment out the following code? I'll keep the callbacks but I'm hoping that this is modular enough that removing it for my own replacement stuff should be safe? Is this a good approach, since I don't need Jacobians/Integrator/Solver since collision response and integration is handled on my side?

    Code (CSharp):
    1.  
    2. // Create contact Jacobians
    3. handle = Solver.ScheduleBuildContactJacobiansJobs(ref input.World.DynamicsWorld, input.TimeStep, math.length(input.Gravity), ref m_Context, handle);
    4. handle = callbacks.Execute(SimulationCallbacks.Phase.PostCreateContactJacobians, this, ref input.World, handle);
    5.  
    6. // Solve all Jacobians
    7. handle = Solver.ScheduleSolveJacobiansJobs(ref input.World.DynamicsWorld, input.TimeStep, input.NumSolverIterations, ref m_Context, handle);
    8. handle = callbacks.Execute(SimulationCallbacks.Phase.PostSolveJacobians, this, ref input.World, handle);
    9.  
    10. // Integrate motions
    11. handle = Integrator.ScheduleIntegrateJobs(ref input.World.DynamicsWorld, input.TimeStep, handle);
     
  3. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    480
    Go for it. You might want to just create your own implementation of ISimulation at this stage :)
     
    Mr-Mechanical likes this.
  4. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    At this point, it seems custom ISimulation is inevitable and it makes sense so that updating Unity Physics doesn't overwrite my code when I update it.

    Though my concern is I am not sure yet how to run a custom ISimulation.

    (Edit: new thread for custom ISimulation discussion:
    https://forum.unity.com/threads/how-to-run-a-custom-isimulation-of-unityphysics.790856/)
     
unityunity