Ignore:
Timestamp:
Feb 16, 2011, 7:04:05 PM (11 years ago)
Author:
sam
Message:

Make the float4x4 constructor fill only the matrix's diagonal. Thus
the float4x4::identity() method is no longer necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/matrix.h

    r648 r651  
    179179{
    180180    inline Mat4() { }
    181     inline Mat4(T val) { for (int i = 0; i < 4; i++) v[i] = val; }
     181    inline Mat4(T val)
     182    {
     183        for (int j = 0; j < 4; j++)
     184            for (int i = 0; i < 4; i++)
     185                v[i][j] = (i == j) ? val : 0;
     186    }
    182187    inline Mat4(Vec4<T> v0, Vec4<T> v1, Vec4<T> v2, Vec4<T> v3)
    183         { v[0] = v0; v[1] = v1; v[2] = v2; v[3] = v3; }
     188    {
     189        v[0] = v0; v[1] = v1; v[2] = v2; v[3] = v3;
     190    }
    184191
    185192    inline Vec4<T>& operator[](int n) { return v[n]; }
    186193    inline Vec4<T> const& operator[](int n) const { return v[n]; }
    187 
    188     static inline Mat4<T> identity()
    189     {
    190         Mat4<T> ret;
    191         for (int j = 0; j < 4; j++)
    192             for (int i = 0; i < 4; i++)
    193                 ret[i][j] = i == j;
    194         return ret;
    195     }
    196194
    197195    T det() const;
Note: See TracChangeset for help on using the changeset viewer.