private void GenerateSphereMeshes()
    {
      foreach( var tuple in listClothBodiesGORadius_ )
      {
        GameObject go = tuple.First;

        if ( go == null)
        {
          continue;
        }
        
        float radius  = tuple.Second;

        Caronte_Fx_Body crBody = go.GetComponent<Caronte_Fx_Body>();
        
        if (crBody != null)
        {
          Mesh colliderMesh;
          Matrix4x4 colliderMatrixModelToWorld;

          bool isBakedColliderMesh = crBody.GetColliderMesh(out colliderMesh, out colliderMatrixModelToWorld );
    
          if (colliderMesh != null)
          {
            AddMeshSpheres(colliderMesh, colliderMatrixModelToWorld, radius);

            if (isBakedColliderMesh)
            {
              UnityEngine.Object.DestroyImmediate(colliderMesh);
            }
          }
        }
      }
    }
Exemplo n.º 2
0
        private bool AreMeshFingerprintsValid(Caronte_Fx_Body fxBody)
        {
            bool isValid = true;

            if (renderFingerprint_ != null)
            {
                Mesh renderMesh;
                bool isBakedMesh = fxBody.GetRenderMesh(out renderMesh);

                if (renderMesh == null)
                {
                    return(false);
                }

                CarGeometryUtils.CalculateFingerprint(renderMesh, fingerprintAux_);
                isValid &= CarGeometryUtils.AreFingerprintsEqual(fingerprintAux_, renderFingerprint_);

                if (isBakedMesh)
                {
                    Object.DestroyImmediate(renderMesh);
                }
            }

            if (colliderFingerprint_ != null)
            {
                Mesh meshToCheck;
                bool isBakedMesh = false;
                if (isRope_)
                {
                    meshToCheck = fxBody.GetTileMesh();
                }
                else
                {
                    isBakedMesh = fxBody.GetColliderMesh(out meshToCheck);
                }

                if (meshToCheck == null)
                {
                    return(false);
                }

                CarGeometryUtils.CalculateFingerprint(meshToCheck, fingerprintAux_);
                isValid &= CarGeometryUtils.AreFingerprintsEqual(fingerprintAux_, colliderFingerprint_);

                if (isBakedMesh)
                {
                    Object.DestroyImmediate(meshToCheck);
                }
            }

            return(isValid);
        }
Exemplo n.º 3
0
        //-----------------------------------------------------------------------------------
        public static void GetColliderMeshData(GameObject go, ref Mesh meshCollider, out Matrix4x4 m_Collider_MODEL_to_WORLD, ref bool isBakedColliderMesh)
        {
            Caronte_Fx_Body bodyComponent = go.GetComponent <Caronte_Fx_Body>();

            isBakedColliderMesh = bodyComponent.GetColliderMesh(out meshCollider, out m_Collider_MODEL_to_WORLD);
        }
Exemplo n.º 4
0
        private bool AreMeshChecksValid(Caronte_Fx_Body fxBody)
        {
            if (colliderType_ != fxBody.ColliderType)
            {
                return(false);
            }

            if (hasValidCollider_ != fxBody.HasValidCollider())
            {
                return(false);
            }

            if (btAsset_ != fxBody.GetBalltreeAsset())
            {
                return(false);
            }
            else
            {
                Mesh colliderMesh;
                bool isBakedMesh = false;
                if (isRope_)
                {
                    colliderMesh = fxBody.GetTileMesh();
                }
                else
                {
                    isBakedMesh = fxBody.GetColliderMesh(out colliderMesh);
                }
                if (colliderFingerprint_ == null && colliderMesh != null ||
                    colliderFingerprint_ != null && colliderMesh == null)
                {
                    if (isBakedMesh)
                    {
                        Object.DestroyImmediate(colliderMesh);
                    }
                    return(false);
                }

                if (isBakedMesh)
                {
                    Object.DestroyImmediate(colliderMesh);
                }
            }

            {
                Mesh renderMesh;
                bool isBakedMesh = fxBody.GetRenderMesh(out renderMesh);

                if (renderFingerprint_ == null && renderMesh != null ||
                    renderFingerprint_ != null && renderMesh == null)
                {
                    if (isBakedMesh)
                    {
                        Object.DestroyImmediate(renderMesh);
                    }
                    return(false);
                }

                if (isBakedMesh)
                {
                    Object.DestroyImmediate(renderMesh);
                }
            }

            return(true);
        }