private static void triggerOnHitObject <T>(T interactionData, IImpactObject otherObject, int physicsMaterialId, bool useMaterialComposition) where T : IInteractionData
 {
     if (otherObject != null)
     {
         if (useMaterialComposition)
         {
             int count = otherObject.GetMaterialCompositionNonAlloc(interactionData.Point, ImpactManagerInstance.MaterialCompositionBuffer);
             for (int i = 0; i < count; i++)
             {
                 ImpactMaterialComposition comp = ImpactManagerInstance.MaterialCompositionBuffer[i];
                 if (comp.CompositionValue > 0)
                 {
                     IInteractionData newInteractionData = interactionData.Clone();
                     newInteractionData.CompositionValue = comp.CompositionValue;
                     ImpactManagerInstance.ProcessInteraction(newInteractionData, comp.Material, otherObject);
                 }
             }
         }
         else
         {
             ImpactManagerInstance.ProcessInteraction(interactionData, otherObject);
         }
     }
     else if (ImpactManagerInstance.UseMaterialMapping)
     {
         IImpactMaterial m;
         if (ImpactManagerInstance.TryGetImpactMaterialFromMapping(physicsMaterialId, out m))
         {
             ImpactManagerInstance.ProcessInteraction(interactionData, m, null);
         }
     }
 }
Example #2
0
        protected ImpactTagMask?getOtherObjectTagMask(IImpactObject impactObject, Vector3 point, int otherPhysicsMaterialID, bool hasOtherObject)
        {
            if (hasOtherObject)
            {
                IImpactMaterial m = impactObject.GetPrimaryMaterial(point);

                if (m != null)
                {
                    return(m.MaterialTagsMask);
                }
                else if (ImpactManagerInstance.UseMaterialMapping && ImpactManagerInstance.TryGetImpactMaterialFromMapping(otherPhysicsMaterialID, out m))
                {
                    return(m.MaterialTagsMask);
                }
            }
            else
            {
                IImpactMaterial m;
                if (ImpactManagerInstance.UseMaterialMapping && ImpactManagerInstance.TryGetImpactMaterialFromMapping(otherPhysicsMaterialID, out m))
                {
                    return(m.MaterialTagsMask);
                }
            }

            return(null);
        }
        private static void triggerOnRaycastingObject <T>(T interactionData, IImpactObject impactObject, IImpactObject otherObject, int physicsMaterialId, bool useMaterialComposition) where T : IInteractionData
        {
            if (otherObject != null)
            {
                if (useMaterialComposition)
                {
                    int count = otherObject.GetMaterialCompositionNonAlloc(interactionData.Point, ImpactManagerInstance.MaterialCompositionBuffer);
                    for (int i = 0; i < count; i++)
                    {
                        ImpactMaterialComposition comp = ImpactManagerInstance.MaterialCompositionBuffer[i];
                        if (comp.CompositionValue > 0)
                        {
                            IInteractionData newInteractionData = interactionData.Clone();
                            newInteractionData.CompositionValue = comp.CompositionValue;
                            newInteractionData.TagMask          = comp.Material.MaterialTagsMask;
                            ImpactManagerInstance.ProcessInteraction(newInteractionData, impactObject);
                        }
                    }
                }
                else
                {
                    IImpactMaterial material = otherObject.GetPrimaryMaterial(interactionData.Point);
                    if (material != null || (ImpactManagerInstance.UseMaterialMapping && ImpactManagerInstance.TryGetImpactMaterialFromMapping(physicsMaterialId, out material)))
                    {
                        interactionData.TagMask = material.MaterialTagsMask;
                    }

                    ImpactManagerInstance.ProcessInteraction(interactionData, impactObject);
                }
            }
            else if (ImpactManagerInstance.UseMaterialMapping)
            {
                IImpactMaterial material;
                if (ImpactManagerInstance.TryGetImpactMaterialFromMapping(physicsMaterialId, out material))
                {
                    interactionData.TagMask = material.MaterialTagsMask;
                }

                ImpactManagerInstance.ProcessInteraction(interactionData, impactObject);
            }
        }