Changeset 2900


Ignore:
Timestamp:
Sep 12, 2013, 3:50:41 PM (6 years ago)
Author:
touky
Message:

camera unit test tweak

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/camera.cpp

    r2897 r2900  
    3838    void SetUp()
    3939    {
    40         eye = vec3(0.f, 50.f, 50.f);
     40        eye = vec3(0.f, 0.f, 50.f);
    4141        target = vec3(0.f);
    4242        up = vec3(0.f, 1.f, 0.f);
     
    8080        TEST_VECTOR(target, tc.GetTarget());
    8181        TEST_VECTOR(up, tc.GetUp());
     82
     83        tc.UseTarget(false);
     84        TEST_VECTOR(vec3(0.f, 0.f, 49.f), tc.GetTarget());
    8285    }
    8386
     
    106109    LOLUNIT_TEST(SetProjectionTest)
    107110    {
    108         mat4 refmx = mat4::perspective(fov, screen_size, screen_ratio, near, far);
     111        mat4 refmx = mat4::perspective(fov, screen_size, screen_size * screen_ratio, near, far);
    109112
    110         tc.SetProjection(refmx);
     113        tc.SetProjection(fov, near, far, screen_size, screen_ratio);
    111114        TEST_MATRIX(refmx, tc.GetProjection());
     115        LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f);
     116        LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f);
     117        LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f);
     118        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
     119        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
     120        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    112121
    113122        tc.SetProjection(fov, near, far);
     
    118127        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    119128        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    120         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
     129        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    121130
    122         tc.SetProjection(fov, near, far, screen_size, screen_ratio);
     131        tc.SetProjection(refmx);
    123132        TEST_MATRIX(refmx, tc.GetProjection());
    124         LOLUNIT_ASSERT_DOUBLES_EQUAL(fov, tc.GetFov(), 1.e-5f);
    125         LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_size, tc.GetScreenSize(), 1.e-5f);
    126         LOLUNIT_ASSERT_DOUBLES_EQUAL(screen_ratio, tc.GetScreenRatio(), 1.e-5f);
    127         LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    128         LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    129         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
    130133
    131134        tc.SetFov(fov);
     
    136139        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    137140        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    138         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
     141        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    139142
    140143        tc.SetScreenInfos(screen_size);
     
    145148        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    146149        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    147         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
     150        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    148151
    149152        tc.SetScreenInfos(screen_size, screen_ratio);
     
    154157        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    155158        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    156         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
     159        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    157160
    158161        tc.SetDrawInfos(far);
     
    163166        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    164167        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    165         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
     168        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    166169
    167170        tc.SetDrawInfos(near, far);
     
    172175        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    173176        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    174         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
     177        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    175178
    176179        is_shifted = true;
     
    184187        LOLUNIT_ASSERT_DOUBLES_EQUAL(near, tc.GetNear(), 1.e-5f);
    185188        LOLUNIT_ASSERT_DOUBLES_EQUAL(far, tc.GetFar(), 1.e-5f);
    186         LOLUNIT_ASSERT(is_shifted != tc.IsShifted());
     189        LOLUNIT_ASSERT(is_shifted == tc.IsShifted());
    187190    }
    188191};
Note: See TracChangeset for help on using the changeset viewer.