//-----------------------------------------------------------------------------------

    private bool AddBodyToLists( GameObject goToUpdate, BD_TYPE type, BodyInfo bodyInfo )
    {
      bool bodyActive = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.ACTIVE)   == BROADCASTFLAG.ACTIVE;
      bool isVisible  = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.VISIBLE)  == BROADCASTFLAG.VISIBLE;
      bool isGhost    = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.GHOST)    == BROADCASTFLAG.GHOST;
      bool isSleeping = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.SLEEPING) == BROADCASTFLAG.SLEEPING;

      bool isInsideTimeInterval = true;
      if ( isChangeToReplayingDone_ )
      {
        Vector2 visibilityInterval = tableVisibilityInterval_[bodyInfo.idBody_];
        isInsideTimeInterval = (currentTime_ >= visibilityInterval.x) && (currentTime_ < visibilityInterval.y);
      }

      bool renderActive = ( (isVisible || isGhost) && isInsideTimeInterval ) 
                          || doDisplayInvisibleBodies_;

      goToUpdate.SetActive(renderActive);

      if ( !renderActive )
      {
        return renderActive;
      }

      if (isVisible)
      {
        if (bodyActive)
        {
          listBodyGOEnabledVisible_.Add(goToUpdate);
        }
        else
        {
          listBodyGODisabledVisible_.Add(goToUpdate);
        }
      }
      else
      {
        if (bodyActive)
        {
          listBodyGOEnabledHide_.Add(goToUpdate);
        }
        else
        {
          listBodyGODisabledHide_.Add(goToUpdate);
        }
      }

      if (isSleeping)
      {
        listBodyGOSleeping_.Add(goToUpdate);
      }

      return renderActive;
    }
    //-----------------------------------------------------------------------------------
    public void UpdateBody( BD_TYPE type, BodyInfo bodyInfo )
    {
      
      Transform trToUpdate = eManager_.GetBodyTransformRef( bodyInfo.idBody_ );

      if ( trToUpdate == null )
        return;

      GameObject goToUpdate = trToUpdate.gameObject;

      bool renderActive = AddBodyToLists( goToUpdate, type, bodyInfo );

      if (renderActive)
      {
        switch (type)
        {
          case BD_TYPE.RIGIDBODY:
            {
              UpdateRigidBody(trToUpdate, bodyInfo);
              break;
            }
        
          case BD_TYPE.BODYMESH_ANIMATED_BY_MATRIX:
            {
              UpdateRigidBody(trToUpdate, bodyInfo);
              break;
            }
          
          case BD_TYPE.BODYMESH_ANIMATED_BY_VERTEX:
            {
              UpdateAnimatedByVertexBody(trToUpdate, bodyInfo);
              break;    
            }

          case BD_TYPE.SOFTBODY:
          case BD_TYPE.CLOTH:
            {
              UpdateVertexBody(trToUpdate, bodyInfo);
              break;
            }
        }
      }
    }// UpdateBody...
Beispiel #3
0
    public void UpdateBody( BD_TYPE type, BodyInfo bodyInfo )
    {
      
      Transform trToUpdate = entityManager_.GetBodyTransformRef( bodyInfo.idBody_ );

      if ( trToUpdate == null )
        return;

      GameObject goToUpdate = trToUpdate.gameObject;

      bool bodyActive   = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.ACTIVE)   == BROADCASTFLAG.ACTIVE;
      bool renderActive = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.VISIBLE)  == BROADCASTFLAG.VISIBLE;
      bool isGhost      = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.GHOST)    == BROADCASTFLAG.GHOST;
      bool isSleeping   = (bodyInfo.broadcastFlag_ & BROADCASTFLAG.SLEEPING) == BROADCASTFLAG.SLEEPING;

      bool renderActiveFlag = (renderActive || doDisplayInvisibleBodies_) && !isGhost;
      goToUpdate.SetActive(renderActiveFlag);

      if ( !renderActiveFlag )
      {
        return;
      }

      if (renderActive)
      {
        if (bodyActive)
        {
          listBodyGOEnabledVisible_.Add(goToUpdate);
        }
        else
        {
          listBodyGODisabledVisible_.Add(goToUpdate);
        }
      }
      else
      {
        if (bodyActive)
        {
          listBodyGOEnabledHide_.Add(goToUpdate);
        }
        else
        {
          listBodyGODisabledHide_.Add(goToUpdate);
        }
      }

      if (isSleeping)
      {
        listBodyGOSleeping_.Add(goToUpdate);
      }

      switch (type)
      {
        case BD_TYPE.RIGIDBODY:
          {
            UpdateRigidBody(trToUpdate, bodyInfo);
            break;
          }
        
        case BD_TYPE.BODYMESH_ANIMATED_BY_MATRIX:
          {
            UpdateRigidBody(trToUpdate, bodyInfo);
            break;
          }
          
        case BD_TYPE.BODYMESH_ANIMATED_BY_VERTEX:
          {
            UpdateAnimatedByVertex(trToUpdate, bodyInfo);
            break;    
          }

        case BD_TYPE.SOFTBODY:
        case BD_TYPE.CLOTH:
          {
            UpdateSoftBody(trToUpdate, bodyInfo);
            break;
          }
      }
    }// UpdateBody