Exemplo n.º 1
0
int main(){
	testChange();

	testSwap();
	
	testLength();
}
bool plRidingAnimatedPhysicalStrategy::ICheckMove(const hsPoint3& startPos, const hsPoint3& desiredPos)
{
    //returns false if it believes the end result can't be obtained by pure application of velocity (collides into somthing that it can't climb up)
    //used as a way to check if it needs to hack getting there like in jumping
    
    uint32_t collideFlags =
    1<<plSimDefs::kGroupStatic |
    1<<plSimDefs::kGroupAvatarBlocker |
    1<<plSimDefs::kGroupDynamic;
    bool hitBottomOfCapsule=false;
    bool hitOther=false;
    float timeOfOtherHits = FLT_MAX;
    float timeFirstBottomHit =  -1.0;
    if(!fCore->IsSeeking())
    {
        collideFlags|=(1<<plSimDefs::kGroupExcludeRegion);
    }
    if((desiredPos.fZ - startPos.fZ) < -1.f)//we will let gravity take care of it when falling
        return true;
    fContactNormals.SetCount(0);
    std::multiset< plControllerSweepRecord > DynamicHits;
    int NumberOfHits=fCore->SweepControllerPath(startPos, desiredPos, true, true, collideFlags, DynamicHits);

    hsPoint3 stepFromPoint;
    hsVector3  movementdir(&startPos, &desiredPos);
    movementdir.Normalize();
    if(NumberOfHits)
    {
        hsPoint3 initBottomPos;
        fCore->GetPositionSim(initBottomPos);
        std::multiset< plControllerSweepRecord >::iterator cur;
        hsVector3 testLength(desiredPos - startPos);
        bool freeMove=true;
        for(cur = DynamicHits.begin();  cur != DynamicHits.end(); cur++)
        {
            if(movementdir.InnerProduct(cur->Norm)>0.01f)
            {
                hsVector3 topOfBottomHemAtTimeT=hsVector3(initBottomPos + testLength * cur->TimeHit );
                topOfBottomHemAtTimeT.fZ = topOfBottomHemAtTimeT.fZ + fCore->GetControllerWidth();
                if(cur->locHit.fZ <= (topOfBottomHemAtTimeT.fZ -.5f))
                {
                    hitBottomOfCapsule=true;
                    hsVector3 norm= hsVector3(-1*(cur->locHit-topOfBottomHemAtTimeT));
                    norm.Normalize();
                    IAddContactNormals(norm);
                }
                else
                {
                    return false;
                }
            }

        }
        return true;
    }
    else
    {
        return true;
    }
    
}
int main(void) {
  assert(testLength() == 0);
  return 0;
}