Search Unity

Resolved [Not-Implemented] Modifying existing collider data

Discussion in 'Physics for ECS' started by Zerio777, Mar 2, 2021.

  1. Zerio777

    Zerio777

    Joined:
    Jan 12, 2015
    Posts:
    24
    So far as I've come, dots physics colliders are all based upon immutable blob assets.

    When making modifications to the mesh data (ie change a vertex value) with the UnityEngine, it's as simple as updating the mesh references for the MeshFilter.mesh and MeshCollider.sharedMesh.

    Trying to do similar in ECS has the entire blob asset being recreated during runtime [ie Unity.Physics.MeshCollider.Create(...)], in every way I come across, which generates the collider much slower.

    Any advice as to how to produce said vertices-changing-at-runtime collider?
     
    Last edited: Mar 2, 2021
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Unfortunately, we don't support mutable meshes. Side note: meshes reuse vertices for neighboring triangles, so changing a vertex will not affect just 1 triangle.

    If you're swapping out a mesh collider, I'd advise you to do it before BuildPhysicsWorld, so that BuildPhysicsWorld jobs can pick it up and create correct bounding volume hierarchy structures internally.
     
  3. Zerio777

    Zerio777

    Joined:
    Jan 12, 2015
    Posts:
    24
    Thanks for the reply, though that's a shame to have confirmed.

    Is this the expected behavior for the foreseeable future? Seems like it'd be a killer for most procedural terrain based games, not having access to mutable ground data work with physics.

    e. Also, creating a new blobassetreference for the physicsCollider for a static entity, when it's already barely in contact with a kinetic entity, often causes the kinetic entity to shoot away from the static entity with unexpected and unrealistic force. Do you know if this is a known issue, or of any solutions?
     
    Last edited: Mar 3, 2021
  4. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    We have mutable compounds and meshes on our radar, but I can't tell much more than that. One thing is certain, though - we take forum feedback seriously and mutable meshes will get a +1 vote.

    By kinetic entity, do you mean dynamic or kinematic? I'd expect that behavior for dynamic that is in penetration with static.
    2 things are important there: don't place new static body in overlap with existing bodies and make the changes before BuildPhysicsWorld or after ExportPhysicsWorld.
     
    Zerio777 likes this.
  5. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    BTW, isn't it easier to add new procedurally generated meshes by creating new ones, rather than changing existing ones?
    I'd expect mesh changes to be convenient for terrain modifications, like destruction (pits) or "growing hills", but adding new tiles sounds way easier with new meshes...