Ejemplo n.º 1
0
 private void UpdateIndex()
 {
     LastParticleConstrainIndex       = pinConstraintBatch.GetConstraintsInvolvingParticle(obiRope.UsedParticles - 1)[0];
     SecondLastParticleConstrainIndex = pinConstraintBatch.GetConstraintsInvolvingParticle(obiRope.UsedParticles - 2)[0];
     FirstParticleConstrainIndex      = pinConstraintBatch.GetConstraintsInvolvingParticle(0)[0];
     SecondParticleConstrainIndex     = pinConstraintBatch.GetConstraintsInvolvingParticle(1)[0];
 }
Ejemplo n.º 2
0
    private void UpdateIndex()
    {
        contraintIndexOne = pinConstraintBatch.GetConstraintsInvolvingParticle(particleIndexOne).Count != 0 ?
                            pinConstraintBatch.GetConstraintsInvolvingParticle(particleIndexOne)[0] : -1;

        contraintIndexTwo = pinConstraintBatch.GetConstraintsInvolvingParticle(particleIndexTwo).Count != 0 ?
                            pinConstraintBatch.GetConstraintsInvolvingParticle(particleIndexTwo)[0] : -1;
    }
Ejemplo n.º 3
0
    private void Start()
    {
        obiRope            = transform.parent.GetComponentInChildren <ObiRope>();
        pinConstrain       = transform.parent.GetComponentInChildren <ObiPinConstraints>();
        pinConstraintBatch = pinConstrain.GetFirstBatch();
        obiSolver          = transform.parent.GetComponentInChildren <ObiSolver>();
        int LastParticleConstrainIndex = pinConstraintBatch.GetConstraintsInvolvingParticle(obiRope.UsedParticles - 1).Count != 0 ?
                                         pinConstraintBatch.GetConstraintsInvolvingParticle(obiRope.UsedParticles - 1)[0] : -1;
        int FirstParticleConstrainIndex = pinConstraintBatch.GetConstraintsInvolvingParticle(0).Count != 0 ?
                                          pinConstraintBatch.GetConstraintsInvolvingParticle(0)[0] : -1;

        if (gameObject == pinConstraintBatch.pinBodies[LastParticleConstrainIndex].gameObject)
        {
            particleIndexOne = obiRope.UsedParticles - 1;
            particleIndexTwo = particleIndexOne - 1;
        }
        else if (gameObject == pinConstraintBatch.pinBodies[FirstParticleConstrainIndex].gameObject)
        {
            particleIndexOne = 0;
            particleIndexTwo = 1;
        }
        else
        {
            particleIndexOne = -1;
            particleIndexTwo = -1;
        }

        if (m_Handle != null)
        {
            m_Handle.InteractableObjectUsed   += M_Handle_InteractableObjectUsed;
            m_Handle.InteractableObjectUnused += M_Handle_InteractableObjectUnused;
        }
        UpdateIndex();
        particleOffsetOne = pinConstraintBatch.pinOffsets[contraintIndexOne];
        particleOffsetTwo = pinConstraintBatch.pinOffsets[contraintIndexTwo];
        Debug.Log(particleOffsetOne);
        Debug.Log(particleOffsetTwo);
        GetComponent <MeshRenderer>().material.color = m_ColorInactive;
    }
Ejemplo n.º 4
0
    private void OnTriggerEnter(Collider other)
    {
        if (!other.CompareTag("Cable"))
        {
            return;
        }
        ObiCollider obicollider = other.GetComponent <ObiCollider>();

        obiRope = other.transform.parent.GetComponentInChildren <ObiRope>();
        ObiPinConstraints pinConstrain = other.transform.parent.GetComponentInChildren <ObiPinConstraints>();

        pinConstraintBatch = pinConstrain.GetFirstBatch();

        Debug.Log("Total Particle" + obiRope.TotalParticles);
        Debug.Log("Used Particle" + obiRope.UsedParticles);
        Debug.Log("Pooled Particle" + obiRope.PooledParticles);

        foreach (var item in pinConstraintBatch.pinBodies)
        {
            Debug.Log(item.gameObject.name);
        }

        foreach (var item in pinConstraintBatch.pinIndices)
        {
            Debug.Log(item);
        }

        foreach (var item in pinConstraintBatch.GetConstraintsInvolvingParticle(particledex))
        {
            Debug.Log("Constrain of Last pariticle" + item);
        }

        pinConstrain.RemoveFromSolver(null);
        UpdateIndex();

        int CheckPoint = 0;

        Debug.Log("CheckPoin" + CheckPoint++);
        UpdateIndex();
        NameOfParticleLast  = pinConstraintBatch.pinBodies[LastParticleConstrainIndex].gameObject.name;
        NameOfParticleFirst = pinConstraintBatch.pinBodies[FirstParticleConstrainIndex].gameObject.name;

        if (other.name == NameOfParticleLast)
        {
            pinConstraintBatch.RemoveConstraint(LastParticleConstrainIndex);
            pinConstraintBatch.AddConstraint(obiRope.UsedParticles - 1, GetComponent <ObiColliderBase>(),
                                             transform.InverseTransformPoint(obiRope.GetParticlePosition(TestRope.UsedParticles - 1)), Quaternion.identity, 0);
            UpdateIndex();
            Debug.Log("CheckPoin" + CheckPoint++);
            pinConstraintBatch.RemoveConstraint(SecondLastParticleConstrainIndex);
            pinConstraintBatch.AddConstraint(obiRope.UsedParticles - 2, GetComponent <ObiColliderBase>(),
                                             transform.InverseTransformPoint(obiRope.GetParticlePosition(TestRope.UsedParticles - 2)), Quaternion.identity, 0);
            Debug.Log("CheckPoin" + CheckPoint++);
        }
        else if (other.name == NameOfParticleFirst)
        {
            pinConstraintBatch.RemoveConstraint(FirstParticleConstrainIndex);
            pinConstraintBatch.AddConstraint(0, GetComponent <ObiColliderBase>(),
                                             transform.InverseTransformPoint(obiRope.GetParticlePosition(0)), Quaternion.identity, 0);
            Debug.Log("CheckPoin" + CheckPoint++);
            UpdateIndex();
            pinConstraintBatch.RemoveConstraint(SecondParticleConstrainIndex);
            pinConstraintBatch.AddConstraint(1, GetComponent <ObiColliderBase>(),
                                             transform.InverseTransformPoint(obiRope.GetParticlePosition(1)), Quaternion.identity, 0);
        }

        pinConstrain.AddToSolver(null);
    }