Announcement

Collapse
No announcement yet.

How to create collision information for procedural geometry?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    ~~~

    AggGeom

    you have to create AggGeom for your mesh component.

    See SphereComponent.cpp for example usage of AggGeom



    Rama
    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    ♥ Rama

    Comment


      #32
      Originally posted by Rama View Post
      ~~~

      AggGeom

      you have to create AggGeom for your mesh component.

      See SphereComponent.cpp for example usage of AggGeom



      Rama
      If I fill out an AggGeom, I can get physics objects to collide with the shapes in the AggGeom. For instance, if I wrap my triangle mesh in a bounding box, I can get objects to bounce off of the bounding box.

      However, I can't seem to get physics objects to collide with the actual triangle mesh itself, even when I set the CollisionTraceFlag to CTF_UseComplexAsSimple. In that case, physics objects just fall right through my triangle mesh.

      My geometry is basically environment geometry, there are many concavities and it does not obey any particular nice shape. I cannot construct a representation for it out of an aggregation of boxes, spheres, and cylinders.

      It should totally be possible to throw a physically simulated sphere or something onto this environment and have it roll down hills and into valleys, etc., colliding with the actual triangles of the mesh, but so far, I'm stuck with the choice of either wrapping my mesh in a convex volume that is far too large, or allowing physics objects to pass through my mesh altogether.

      Has anyone figured out how to get physics objects to collide with the actual triangles of a triangle mesh? Thanks in advance!

      Comment


        #33
        Originally posted by sgorsten View Post
        Has anyone figured out how to get physics objects to collide with the actual triangles of a triangle mesh? Thanks in advance!
        Sorry I told you to post here in my message, but you already had.

        As I mention, maybe the mesh collision profile needs to be set:

        Code:
        SetCollisionProfileName(UCollisionProfile::BlockAll_ProfileName);

        Otherwise, looking at the collision information in play mode with a spawned procedurally generated object might yield some clues.
        It is by will alone I set my code in motion.
        It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
        It is by will alone I set my code in motion.

        Comment


          #34
          Originally posted by sgorsten View Post
          Has anyone figured out how to get physics objects to collide with the actual triangles of a triangle mesh?
          For static geometry, setting 'use complex as simple' as the Collision Complexity in the StaticMesh Editor will cause physics to collide with the graphics triangles. We do not support per-poly collision on the actual physics object - we need collision geometry with 'volume' so we can calculate mass/inertia etc., and it would be too slow.
          Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
          Twitter: @EpicJamesG

          Comment


            #35
            SetMobility(EComponentMobility::Stationary);

            Hey sgorsten,

            Yeah I was having the same problem myself for a while, an as usual the solution turned out to be a one line fix.

            To get the generated mesh working with physics you'll just need to make sure you set the mobility of the component to Static or Stationary as the component will default to movable.

            Code:
            SetMobility(EComponentMobility::Stationary);
            This should get physics objects colliding with your generated mesh, its even happy if your deforming or updating the mesh while its colliding as I'm using destructible terrain in some situations.

            The Stationary mobility option still lets you move your component as well with collision working, but obviously that movement needs to be blueprint or code driven from JamesG comment above about per-poly on physics objects.

            This all seems happy in the editor simulating and dropping to game, an hopefully with the work being done in the related thread we'll have the cooked PhysX data in the built projects for 4.2 or 4.3.

            Comment


              #36
              @Kaos Nova

              Welcome to the forums Kaos Nova!

              Congrats on your first post!

              And thanks for sharing!



              Rama
              UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

              ♥ Rama

              Comment


                #37
                Originally posted by Kaos Nova View Post
                Hey sgorsten,

                Yeah I was having the same problem myself for a while, an as usual the solution turned out to be a one line fix.

                To get the generated mesh working with physics you'll just need to make sure you set the mobility of the component to Static or Stationary as the component will default to movable.

                Code:
                SetMobility(EComponentMobility::Stationary);
                This should get physics objects colliding with your generated mesh, its even happy if your deforming or updating the mesh while its colliding as I'm using destructible terrain in some situations.

                The Stationary mobility option still lets you move your component as well with collision working, but obviously that movement needs to be blueprint or code driven from JamesG comment above about per-poly on physics objects.

                This all seems happy in the editor simulating and dropping to game, an hopefully with the work being done in the related thread we'll have the cooked PhysX data in the built projects for 4.2 or 4.3.
                Thank you so much! This simple one-liner makes it work!

                Comment

                Working...
                X