Ejemplo n.º 1
0
        void GetInputDataFromAuthoringComponent(T shape)
        {
            if (!ShouldConvertShape(shape))
            {
                return;
            }

            var body = GetPrimaryBody(shape);

            var instance = new ColliderInstance
            {
                AuthoringComponentId = shape.GetInstanceID(),
                BodyEntity           = GetPrimaryEntity(body),
                ShapeEntity          = GetPrimaryEntity(shape),
                BodyFromShape        = ColliderInstance.GetCompoundFromChild(shape.transform, body.transform)
            };

            var data = GenerateComputationData(shape, instance, m_ConvexColliderPoints, m_MeshColliderVertices, m_MeshColliderTriangles);

            data.Instance.ConvertedAuthoringComponentIndex = m_EndColliderConversionSystem.PushAuthoringComponent(shape);
            data.Instance.ConvertedBodyTransformIndex      = m_EndColliderConversionSystem.PushAuthoringComponent(body.transform);
            m_ShapeComputationData.Add(data);

            if (body == shape.gameObject)
            {
                DstEntityManager.RemoveParentAndSetWorldTranslationAndRotation(instance.BodyEntity, body.transform);
            }
        }
        void GetInputDataFromAuthoringComponent(T shape)
        {
            var body = GetPrimaryBody(shape);

            var instance = new ColliderInstance
            {
                AuthoringComponentId = shape.GetInstanceID(),
                BodyEntity           = GetPrimaryEntity(body),
                ShapeEntity          = GetPrimaryEntity(shape),
                BodyFromShape        = ColliderInstance.GetCompoundFromChild(shape.transform, body.transform)
            };

            var data = GenerateComputationData(shape, instance, m_ConvexColliderPoints, m_MeshColliderVertices, m_MeshColliderTriangles, m_MeshAssets);

            data.Instance.ConvertedAuthoringComponentIndex = m_EndColliderConversionSystem.PushAuthoringComponent(shape);
            data.Instance.ConvertedBodyTransformIndex      = m_EndColliderConversionSystem.PushAuthoringComponent(body.transform);
            m_ShapeComputationData.Add(data);

            if (BlobComputationContext.NeedToComputeBlobAsset(data.Instance.Hash))
            {
                if (data.ShapeType == ShapeType.ConvexHull)
                {
                    m_ConvexColliderJobs.TryAdd(data.Instance.Hash, data.ConvexHullProperties);
                }
                else if (data.ShapeType == ShapeType.Mesh)
                {
                    m_MeshColliderJobs.TryAdd(data.Instance.Hash, data.MeshProperties);
                }
            }

            foreach (var mesh in m_MeshAssets)
            {
                if (mesh != null)
                {
                    DeclareAssetDependency(shape.gameObject, mesh);
                }
            }

            m_MeshAssets.Clear();

            if (body == shape.gameObject)
            {
                DstEntityManager.PostProcessTransformComponents(instance.BodyEntity, body.transform, BodyMotionType.Static);
            }
        }