Beispiel #1
0
// Called every frame
void AShip::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	calculateMovement();
	turnShip(DeltaTime);
	//GetWorld()->GetAuthGameMode()->check
}
Beispiel #2
0
float TargetingControl::estimatePlayerPotentialVisiblityChange(physent* target)
{
    fpsent* fpsEntity = dynamic_cast<fpsent*>(target);
    vec center = fpsEntity->getcenter();
    int movement = calculateMovement(fpsEntity)/1.732f; // We use a uniform vector for simplicity, so divide by sqrt{3}
    vec movementVector = vec(movement, movement, movement);
    return estimatePotentialVisibilityChange(
        camera1->o, curfov, fovy, camdir, camright, camup, center,
        max(fpsEntity->radius, fpsEntity->getheight()), movementVector
    );
}
Beispiel #3
0
void TargetingControl::calcPhysicsFrames(physent *entity)
{
    // XXX: Note that at 200fps we now see bad movement stutter. Look at the original
    // sauer code in physics.cpp that was the basis for this function to see if perhaps
    // they now do thins differently. To debug this, revert back to sauer's method
    // of NON-per-entity physics and see what that changes.

    fpsent* fpsEntity = (fpsent*)entity;

    logger::log(logger::INFO, "physicsframe() lastmillis: %d  curtime: %d  lastphysframe: %d\r\n", lastmillis, curtime, fpsEntity->lastphysframe);

    // If no previous physframe - this is the first time - then don't bother
    // running physics, wait for that first frame. Or else we might run
    // a lot of frames for nothing at this stage (all the way back to time '0')
    if (fpsEntity->lastphysframe == 0)
        fpsEntity->lastphysframe = lastmillis; // Will induce diff=0 for this frame

    int diff = lastmillis - fpsEntity->lastphysframe; // + curtime
    if(diff <= 0) fpsEntity->physsteps = 0;
    else
    {
        int entityFrameTime;

#ifdef SERVER
        entityFrameTime = (calculateMovement(fpsEntity) >= 0.001) ? 15 : 30;
#else
        entityFrameTime = (fpsEntity == player) ? 5 : 10;
#endif
        fpsEntity->physframetime = entityFrameTime; // WAS: clamp((entityFrameTime*gamespeed)/100, 1, entityFrameTime);

        fpsEntity->physsteps = (diff + fpsEntity->physframetime - 1)/fpsEntity->physframetime;
        fpsEntity->lastphysframe += fpsEntity->physsteps * fpsEntity->physframetime;

        fpsEntity->lastPhysicsPosition = fpsEntity->o;
    }

    if (fpsEntity->physsteps * fpsEntity->physframetime > 2000)
    {
        logger::log(logger::WARNING, "Trying to run over 2 seconds of physics prediction at once for %d: %d/%d (%d fps) (diff: %d ; %d, %d). Aborting physics for this round.\r\n", fpsEntity->uniqueId, fpsEntity->physframetime, fpsEntity->physsteps, 1000/fpsEntity->physframetime, diff, lastmillis, fpsEntity->lastphysframe - (fpsEntity->physsteps * fpsEntity->physframetime));
        fpsEntity->physsteps = 1; // If we had a ton of physics to run - like, say, after 19 seconds of lightmap calculations -
        // then just give up, don't run all that physics, do just one frame. Back to normal next time, after all.
    }

    logger::log(logger::INFO, "physicsframe() Decided on physframetime/physsteps: %d/%d (%d fps) (diff: %d)\r\n", fpsEntity->physframetime, fpsEntity->physsteps, 1000/fpsEntity->physframetime, diff);
}
Beispiel #4
0
void TargetingControl::calcPhysicsFrames(physent *entity)
{
    // XXX: Note that at 200fps we now see bad movement stutter. Look at the original
    // sauer code in physics.cpp that was the basis for this function to see if perhaps
    // they now do thins differently. To debug this, revert back to sauer's method
    // of NON-per-entity physics and see what that changes.

    fpsent* fpsEntity = dynamic_cast<fpsent*>(entity);

    Logging::log(Logging::INFO, "physicsframe() lastmillis: %d  curtime: %d  lastphysframe: %d\r\n", lastmillis, curtime, fpsEntity->lastphysframe);

    // If no previous physframe - this is the first time - then don't bother
    // running physics, wait for that first frame. Or else we might run
    // a lot of frames for nothing at this stage (all the way back to time '0')
    if (fpsEntity->lastphysframe == 0)
        fpsEntity->lastphysframe = lastmillis; // Will induce diff=0 for this frame

    int diff = lastmillis - fpsEntity->lastphysframe; // + curtime
    if(diff <= 0) fpsEntity->physsteps = 0;
    else
    {
        // Kripken: Use an configurable frame time. In particular this lets the server use a slower rate
        int entityFrameTime;

        #ifdef CLIENT
            if (fpsEntity == player)
            {
                entityFrameTime = Utility::Config::getInt("Physics", "player_frame_time", PHYSFRAMETIME);
            } else {
                // For other clients, we pick the frame time in an visibility-dependent way
                entityFrameTime = Utility::Config::getInt("Physics", "frame_time", PHYSFRAMETIME);

                if (Utility::Config::getInt("Physics", "adaptive", 0))
                {
                    // Visible size in pixels (2D coordinates)
                    int pixelChange = max(1.0f, GETIV(scr_w)*GETIV(scr_h)*(estimatePlayerPotentialVisiblityChange(fpsEntity)/100.0f));

                    entityFrameTime = clamp(int(entityFrameTime*20000.0f/pixelChange),
                                            entityFrameTime, // min of the default setting - never go lower than that
                                            MAXFRAMETIME);
                }
            }
        #else // SERVER

            // Simple adaptivity to velocity changes - experimental
//            if (dynamic_cast<fpsent*>(fpsEntity)->serverControlled) Disable this and MAXFRAMETIME for now - buggy (fall through floor)
            {
                float movement = calculateMovement(fpsEntity);
                if (movement >= 0.001 || !Utility::Config::getInt("Physics", "adaptive", 0))
                    entityFrameTime = Utility::Config::getInt("Physics", "frame_time", PHYSFRAMETIME);
                else
                    entityFrameTime = Utility::Config::getInt("Physics", "frame_time", PHYSFRAMETIME) * 2; // Conservative speedup
            }
//            } else
//                entityFrameTime = MAXFRAMETIME; // Low physics for non-controlled entities
        #endif
                
        fpsEntity->physframetime = entityFrameTime; // WAS: clamp((entityFrameTime*gamespeed)/100, 1, entityFrameTime);

        fpsEntity->physsteps = (diff + fpsEntity->physframetime - 1)/fpsEntity->physframetime;
        fpsEntity->lastphysframe += fpsEntity->physsteps * fpsEntity->physframetime;

        fpsEntity->lastPhysicsPosition = fpsEntity->o;
    }

    if (fpsEntity->physsteps * fpsEntity->physframetime > 2000)
    {
        Logging::log(Logging::WARNING, "Trying to run over 2 seconds of physics prediction at once for %d: %d/%d (%d fps) (diff: %d ; %d, %d). Aborting physics for this round.\r\n", fpsEntity->uniqueId, fpsEntity->physframetime, fpsEntity->physsteps, 1000/fpsEntity->physframetime, diff, lastmillis, fpsEntity->lastphysframe - (fpsEntity->physsteps * fpsEntity->physframetime));
        fpsEntity->physsteps = 1; // If we had a ton of physics to run - like, say, after 19 seconds of lightmap calculations -
                                  // then just give up, don't run all that physics, do just one frame. Back to normal next time, after all.
    }

    Logging::log(Logging::INFO, "physicsframe() Decided on physframetime/physsteps: %d/%d (%d fps) (diff: %d)\r\n", fpsEntity->physframetime, fpsEntity->physsteps, 1000/fpsEntity->physframetime, diff);
}