Browse Source

Update Core, IO, Math Lua API.

Aster Jian 12 years ago
parent
commit
6ba4451ffd

+ 1 - 1
Extras/LuaScript/pkgs/Audio/Audio.pkg

@@ -39,7 +39,7 @@ public:
     tolua_readonly tolua_property__get_set int mixRate;
     tolua_readonly tolua_property__get_set bool interpolation;
 
-tolua_property__get_set SoundListener* listener;
+    tolua_property__get_set SoundListener* listener;
     tolua_readonly tolua_property__is_set bool stereo;    
     tolua_readonly tolua_property__is_set bool playing;
     tolua_readonly tolua_property__is_set bool initialized;

+ 0 - 20
Extras/LuaScript/pkgs/Container/Ptr.pkg

@@ -1,20 +0,0 @@
-$#include "RenderPath.h"
-$#include "Ptr.h"
-
-/// Shared pointer template class with intrusive reference counting.
-class SharedPtr
-{
-    TOLUA_TEMPLATE_BIND(T, RenderPath)
-public:
-    /// Point to the object.
-    bool operator < (const SharedPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
-    /// Test for equality with another shared pointer.
-    bool operator == (const SharedPtr<T>& rhs) const { return ptr_ == rhs.ptr_; }
-    
-    /// Check if the pointer is null.
-    bool Null() const { return ptr_ == 0; }
-    /// Check if the pointer is not null.
-    bool NotNull() const { return ptr_ != 0; }
-    /// Return the raw pointer.
-    T* Get() const { return ptr_; }
-};

+ 43 - 207
Extras/LuaScript/pkgs/Container/Str.pkg

@@ -1,242 +1,78 @@
 $#include "Str.h"
 
-/// %String class.
 class String
 {
-public:
-    /// Construct empty.
-    String() :
-        length_(0),
-        capacity_(0),
-        buffer_(&endZero)
-    {
-    }
-    
-    /// Construct from another string.
-    String(const String& str) :
-        length_(0),
-        capacity_(0),
-        buffer_(&endZero)
-    {
-        *this = str;
-    }
-    
-    /// Construct from a C string.
-    String(const char* str) :
-        length_(0),
-        capacity_(0),
-        buffer_(&endZero)
-    {
-        *this = str;
-    }
-    
-    /// Construct from a C string.
-    String(char* str) :
-        length_(0),
-        capacity_(0),
-        buffer_(&endZero)
-    {
-        *this = (const char*)str;
-    }
-    
-    /// Construct from a char array and length.
-    String(const char* str, unsigned length) :
-        length_(0),
-        capacity_(0),
-        buffer_(&endZero)
-    {
-        Resize(length);
-        CopyChars(buffer_, str, length);
-    }
-    
-    /// Construct from an integer.
-    explicit String(int value);
-    /// Construct from a short integer.
-    explicit String(short value);
-    /// Construct from a long integer.
-    explicit String(long value);
-    /// Construct from a long long integer.
-    explicit String(long long value);
-    /// Construct from an unsigned integer.
-    explicit String(unsigned value);
-    /// Construct from an unsigned short integer.
-    explicit String(unsigned short value);
-    /// Construct from an unsigned long integer.
-    explicit String(unsigned long value);
-    /// Construct from an unsigned long long integer.
-    explicit String(unsigned long long value);
-    /// Construct from a float.
-    explicit String(float value);
-    /// Construct from a double.
-    explicit String(double value);
-    /// Construct from a bool.
-    explicit String(bool value);
-    /// Construct from a character.
-    explicit String(char value);
-    /// Construct from a character and fill length.
-    explicit String(char value, unsigned length);
-    
-    /// Destruct.
-    ~String()
-    {
-        if (capacity_)
-            delete[] buffer_;
-    }
-    
-    /// Add a string.
-    String operator + (const String& rhs) const
-    {
-        String ret;
-        ret.Resize(length_ + rhs.length_);
-        CopyChars(ret.buffer_, buffer_, length_);
-        CopyChars(ret.buffer_ + length_, rhs.buffer_, rhs.length_);
-        
-        return ret;
-    }
-    
-    /// Add a C string.
-    String operator + (const char* rhs) const
-    {
-        unsigned rhsLength = CStringLength(rhs);
-        String ret;
-        ret.Resize(length_ + rhsLength);
-        CopyChars(ret.buffer_, buffer_, length_);
-        CopyChars(ret.buffer_ + length_, rhs, rhsLength);
-        
-        return ret;
-    }
-    
-    /// Add a character.
-    String operator + (char rhs) const
-    {
-        String ret(*this);
-        ret += rhs;
-        
-        return ret;
-    }
-    
-    /// Test for equality with another string.
-    bool operator == (const String& rhs) const { return strcmp(CString(), rhs.CString()) == 0; }
+    String();
+    String(const String& str);
+    String(const char* str);
+    String(const char* str, unsigned length);
+    ~String();
+    
+    String operator + (const String& rhs) const;
+    String operator + (const char* rhs) const;
+    
+    bool operator == (const String& rhs) const;
+    bool operator == (const char* rhs) const;
     tolua_outside bool StringEq @ Eq(const String& rhs) const;
-    /// Test if string is less than another string.
-    bool operator < (const String& rhs) const { return strcmp(CString(), rhs.CString()) < 0; }
-    bool operator == (const char* rhs) const { return strcmp(CString(), rhs) == 0; }
-    tolua_outside bool StringEq @ Eq(const char* rhs) const;
-    /// Test if string is less than a C string.
-    bool operator < (const char* rhs) const { return strcmp(CString(), rhs) < 0; }
-    /// Return char at index.
-    char& operator [] (unsigned index) { assert(index < length_); return buffer_[index]; }
-    /// Return const char at index.
-    const char& operator [] (unsigned index) const { assert(index < length_); return buffer_[index]; }
-    /// Return char at index.
-    char& At(unsigned index) { assert(index < length_); return buffer_[index]; }
-    /// Return const char at index.
-    const char& At(unsigned index) const { assert(index < length_); return buffer_[index]; }
-    
-    /// Replace all occurrences of a character.
-    void Replace(char replaceThis, char replaceWith);
-    /// Replace all occurrences of a string.
+    tolua_outside bool StringEq @ Eq(const char*& rhs) const;
+    
     void Replace(const String& replaceThis, const String& replaceWith);
-    /// Replace a substring.
+    void Replace(const char* replaceThis, const char* replaceWith);
+    
     void Replace(unsigned pos, unsigned length, const String& replaceWith);
-    /// Return a string with all occurrences of a character replaced.
-    String Replaced(char replaceThis, char replaceWith) const;
-    /// Return a string with all occurrences of a string replaced.
+    void Replace(unsigned pos, unsigned length, const char* replaceWith);
+    
     String Replaced(const String& replaceThis, const String& replaceWith) const;
-    /// Append a string.
+    String Replaced(const char* replaceThis, const char* replaceWith) const;
+    
     String& Append(const String& str);
-    /// Append a C string.
     String& Append(const char* str);
-    /// Append a character.
-    String& Append(char c);
-    /// Append characters.
     String& Append(const char* str, unsigned length);
-    /// Insert a string.
+    
     void Insert(unsigned pos, const String& str);
-    /// Insert a character.
     void Insert(unsigned pos, char c);
-    /// Erase a substring.
     void Erase(unsigned pos, unsigned length = 1);
-    /// Resize the string.
     void Resize(unsigned newLength);
-    /// Set new capacity.
     void Reserve(unsigned newCapacity);
-    /// Reallocate so that no extra memory is used.
     void Compact();
-    /// Clear the string.
     void Clear();
-    /// Swap with another string.
-    void Swap(String& str);
-    
-    /// Return first char, or 0 if empty.
-    char Front() const { return buffer_[0]; }
-    /// Return last char, or 0 if empty.
-    char Back() const { return length_ ? buffer_[length_ - 1] : buffer_[0]; }
-    /// Return a substring from position to end.
+    
     String Substring(unsigned pos) const;
-    /// Return a substring with length from position.
     String Substring(unsigned pos, unsigned length) const;
-    /// Return string with whitespace trimmed from the beginning and the end.
     String Trimmed() const;
-    /// Return string in uppercase.
+    
     String ToUpper() const;
-    /// Return string in lowercase.
     String ToLower() const;
-    /// Return substrings split by a separator char.
-    Vector<String> Split(char separator) const;
-    /// Join substrings with a 'glue' string.
-    void Join(const Vector<String>& subStrings, String glue);
-    /// Return index to the first occurrence of a string, or NPOS if not found.
+    
     unsigned Find(const String& str, unsigned startPos = 0) const;
-    /// Return index to the first occurrence of a character, or NPOS if not found.
-    unsigned Find(char c, unsigned startPos = 0) const;
-    /// Return index to the last occurrence of a string, or NPOS if not found.
+    unsigned Find(const char* str, unsigned startPos = 0) const;
+    
     unsigned FindLast(const String& str, unsigned startPos = String::NPOS) const;
-    /// Return index to the last occurrence of a character, or NPOS if not found.
-    unsigned FindLast(char c, unsigned startPos = String::NPOS) const;
-    /// Return whether starts with a string.
+    unsigned FindLast(const char* str, unsigned startPos = String::NPOS) const;
+    
     bool StartsWith(const String& str) const;
-    /// Return whether ends with a string.
+    bool StartsWith(const char* str) const;
     bool EndsWith(const String& str) const;
-    /// Return the C string.
-    const char* CString() const { return buffer_; }
-    /// Return length.
-    unsigned Length() const { return length_; }
-    /// Return buffer capacity.
-    unsigned Capacity() const { return capacity_; }
-    /// Return whether the string is empty.
-    bool Empty() const { return length_ == 0; }
-    /// Return comparision result with a string.
+    bool EndsWith(const char* str) const;
+    
+    const char* CString() const;
+    unsigned Length() const;
+    unsigned Capacity() const;
+    bool Empty() const;
     int Compare(const String& str, bool caseSensitive = true) const;
-    /// Return comparision result with a C string.
     int Compare(const char* str, bool caseSensitive = true) const;
-    /// Return whether contains a specific occurences of string.
-    bool Contains(const String& str) const { return Find(str) != String::NPOS; }
-    /// Return whether contains a specific character.
-    bool Contains(char c) const { return Find(c) != String::NPOS; }
-
-    /// Return hash value for HashSet & HashMap.
-    unsigned ToHash() const
-    {
-        unsigned hash = 0;
-        const char* ptr = buffer_;
-        while (*ptr)
-        {
-            hash = *ptr + (hash << 6) + (hash << 16) - hash;
-            ++ptr;
-        }
-        
-        return hash;
-    }
-    
-    /// Compare two C strings.
+    bool Contains(const String& str) const;
+    
+    unsigned ToHash() const;
+    
     static int Compare(const char* str1, const char* str2, bool caseSensitive);
-    /// Position for "not found."
+    
     static const unsigned NPOS;
-    /// Initial dynamic allocation size.
-    static const unsigned MIN_CAPACITY;
-    /// Empty string.
     static const String EMPTY;
+    
+    tolua_readonly tolua_property__no_prefix unsigned length;
+    tolua_readonly tolua_property__no_prefix unsigned capacity;
+    tolua_readonly tolua_property__no_prefix bool empty;
 };
 
 ${

+ 66 - 374
Extras/LuaScript/pkgs/Container/Vector.pkg

@@ -1,408 +1,100 @@
 $#include "Vector.h"
 $#include "Vector3.h"
 
-/// %Vector template class.
 class Vector : public VectorBase
 {
     TOLUA_TEMPLATE_BIND(T, String)
-public:
-    /// Construct empty.
-    Vector()
-    {
-    }
-    
-    /// Construct with initial size.
-    explicit Vector(unsigned size)
-    {
-        Resize(size, 0);
-    }
-    
-    /// Construct with initial data.
-    Vector(const T* data, unsigned size)
-    {
-        Resize(size, data);
-    }
-    
-    /// Construct from another vector.
-    Vector(const Vector<T>& vector)
-    {
-        *this = vector;
-    }
-    
-    /// Destruct.
-    ~Vector()
-    {
-        Clear();
-        delete[] buffer_;
-    }
-    
-    /// Add an element.
-    Vector<T> operator + (const T& rhs) const
-    {
-        Vector<T> ret(*this);
-        ret.Push(rhs);
-        return ret;
-    }
+
+    Vector();
+    Vector(const Vector<T>& vector);
+    ~Vector();
     
-    /// Add another vector.
-    Vector<T> operator + (const Vector<T>& rhs) const
-    {
-        Vector<T> ret(*this);
-        ret.Push(rhs);
-        return ret;
-    }
+    Vector<T> operator + (const T& rhs) const;
+    Vector<T> operator + (const Vector<T>& rhs) const;
     
-    /// Test for equality with another vector.
-    bool operator == (const Vector<T>& rhs) const
-    {
-        if (rhs.size_ != size_)
-            return false;
-        
-        T* buffer = Buffer();
-        T* rhsBuffer = rhs.Buffer();
-        for (unsigned i = 0; i < size_; ++i)
-        {
-            if (buffer[i] != rhsBuffer[i])
-                return false;
-        }
-        
-        return true;
-    }
+    bool operator == (const Vector<T>& rhs) const;
     
-    /// Return element at index.
-    T& operator [] (unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index.
-    const T& operator [] (unsigned index) const { assert(index < size_); return Buffer()[index]; }
-    /// Return element at index.
-    T& At(unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index.
-    const T& At(unsigned index) const { assert(index < size_); return Buffer()[index]; }
-
-    /// Add an element at the end.
-    void Push(const T& value) { Resize(size_ + 1, &value); }
-    /// Add another vector at the end.
-    void Push(const Vector<T>& vector) { Resize(size_ + vector.size_, vector.Buffer()); }
+    T& operator [] (unsigned index);
+    const T& operator [] (unsigned index) const;
+    T& At(unsigned index);
+    const T& At(unsigned index) const;
     
-    /// Remove the last element.
-    void Pop()
-    {
-        if (size_)
-            Resize(size_ - 1, 0);
-    }
+    void Push(const T& value);
+    void Push(const Vector<T>& vector);
+    void Pop();
     
-    /// Insert an element at position.
-    void Insert(unsigned pos, const T& value)
-    {
-        if (pos > size_)
-            pos = size_;
-        
-        unsigned oldSize = size_;
-        Resize(size_ + 1, 0);
-        MoveRange(pos + 1, pos, oldSize - pos);
-        Buffer()[pos] = value;
-    }
+    void Insert(unsigned pos, const T& value);
+    void Insert(unsigned pos, const Vector<T>& vector);
+    void Erase(unsigned pos, unsigned length = 1);
     
-    /// Insert another vector at position.
-    void Insert(unsigned pos, const Vector<T>& vector)
-    {
-        if (pos > size_)
-            pos = size_;
-        
-        unsigned oldSize = size_;
-        Resize(size_ + vector.size_, 0);
-        MoveRange(pos + vector.size_, pos, oldSize - pos);
-        CopyElements(Buffer() + pos, vector.Buffer(), vector.size_);
-    }
-    /// Erase a range of elements.
-    void Erase(unsigned pos, unsigned length = 1)
-    {
-        // Return if the range is illegal
-        if (pos + length > size_ || !length)
-            return;
-        
-        MoveRange(pos, pos + length, size_ - pos - length);
-        Resize(size_ - length, 0);
-    }
-       
-    /// Erase an element if found.
-    bool Remove(const T& value)
-    {
-        Iterator i = Find(value);
-        if (i != End())
-        {
-            Erase(i);
-            return true;
-        }
-        else
-            return false;
-    }
+    bool Remove(const T& value);
+    void Clear();
     
-    /// Clear the vector.
-    void Clear() { Resize(0); }
-    /// Resize the vector.
-    void Resize(unsigned newSize) { Resize(newSize, 0); }
+    void Resize(unsigned newSize);
+    void Reserve(unsigned newCapacity);
+    void Compact();
     
-    /// Set new capacity.
-    void Reserve(unsigned newCapacity)
-    {
-        if (newCapacity < size_)
-            newCapacity = size_;
-        
-        if (newCapacity != capacity_)
-        {
-            T* newBuffer = 0;
-            capacity_ = newCapacity;
-            
-            if (capacity_)
-            {
-                newBuffer = reinterpret_cast<T*>(AllocateBuffer(capacity_ * sizeof(T)));
-                // Move the data into the new buffer
-                ConstructElements(newBuffer, Buffer(), size_);
-            }
-            
-            // Delete the old buffer
-            DestructElements(Buffer(), size_);
-            delete[] buffer_;
-            buffer_ = reinterpret_cast<unsigned char*>(newBuffer);
-        }
-    }
+    bool Contains(const T& value) const;
     
-    /// Reallocate so that no extra memory is used.
-    void Compact() { Reserve(size_); }
+    T& Front();
+    const T& Front() const;
+    T& Back();
+    const T& Back() const;
     
-    /// Return whether contains a specific value.
-    bool Contains(const T& value) const { return Find(value) != End(); }
+    unsigned Size() const;
+    unsigned Capacity() const;
+    bool Empty() const;
     
-    /// Return first element.
-    T& Front() { assert(size_); return Buffer()[0]; }
-    /// Return const first element.
-    const T& Front() const { assert(size_); return Buffer()[0]; }
-    /// Return last element.
-    T& Back() { assert(size_); return Buffer()[size_ - 1]; }
-    /// Return const last element.
-    const T& Back() const { assert(size_); return Buffer()[size_ - 1]; }
-    /// Return size of vector.
-    unsigned Size() const { return size_; }
-    /// Return capacity of vector.
-    unsigned Capacity() const { return capacity_; }
-    /// Return whether vector is empty.
-    bool Empty() const { return size_ == 0; }    
+    tolua_readonly tolua_property__no_prefix unsigned size;
+    tolua_readonly tolua_property__no_prefix unsigned capacity;
+    tolua_readonly tolua_property__no_prefix bool empty;
 };
 
-/// %Vector template class for POD types. Does not call constructors or destructors and uses block move.
 class PODVector
 {
     TOLUA_TEMPLATE_BIND(T, Vector3)
-public:   
-    /// Construct empty.
-    PODVector()
-    {
-    }
-    
-    /// Construct with initial size.
-    explicit PODVector(unsigned size)
-    {
-        Resize(size);
-    }
     
-    /// Construct with initial data.
-    PODVector(const T* data, unsigned size)
-    {
-        Resize(size);
-        CopyElements(Buffer(), data, size);
-    }
+    PODVector();
+    PODVector(const PODVector<T>& vector);
+    ~PODVector();
     
-    /// Destruct.
-    ~PODVector()
-    {
-        delete[] buffer_;
-    }
+    PODVector<T> operator + (const T& rhs) const;
+    PODVector<T> operator + (const PODVector<T>& rhs) const;
     
-    /// Add an element.
-    PODVector<T> operator + (const T& rhs) const
-    {
-        PODVector<T> ret(*this);
-        ret.Push(rhs);
-        return ret;
-    }
+    bool operator == (const PODVector<T>& rhs) const;
     
-    /// Add another vector.
-    PODVector<T> operator + (const PODVector<T>& rhs) const
-    {
-        PODVector<T> ret(*this);
-        ret.Push(rhs);
-        return ret;
-    }
+    T& operator [] (unsigned index);
+    const T& operator [] (unsigned index) const;
+    T& At(unsigned index);
+    const T& At(unsigned index) const;
     
-    /// Test for equality with another vector.
-    bool operator == (const PODVector<T>& rhs) const
-    {
-        if (rhs.size_ != size_)
-            return false;
-        
-        T* buffer = Buffer();
-        T* rhsBuffer = rhs.Buffer();
-        for (unsigned i = 0; i < size_; ++i)
-        {
-            if (buffer[i] != rhsBuffer[i])
-                return false;
-        }
-        
-        return true;
-    }
+    void Push(const T& value);
+    void Push(const PODVector<T>& vector);
+    void Pop();
     
-    /// Return element at index.
-    T& operator [] (unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index.
-    const T& operator [] (unsigned index) const { assert(index < size_); return Buffer()[index]; }
-    /// Return element at index.
-    T& At(unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index.
-    const T& At(unsigned index) const { assert(index < size_); return Buffer()[index]; }
+    void Insert(unsigned pos, const T& value);
+    void Insert(unsigned pos, const PODVector<T>& vector);
+    void Erase(unsigned pos, unsigned length = 1);
     
-    /// Add an element at the end.
-    void Push(const T& value)
-    {
-        if (size_ < capacity_)
-            ++size_;
-        else
-            Resize(size_ + 1);
-        Back() = value;
-    }
+    bool Remove(const T& value);
+    void Clear();
     
-    /// Add another vector at the end.
-    void Push(const PODVector<T>& vector)
-    {
-        unsigned oldSize = size_;
-        Resize(size_ + vector.size_);
-        CopyElements(Buffer() + oldSize, vector.Buffer(), vector.size_);
-    }
+    void Resize(unsigned newSize);
+    void Reserve(unsigned newCapacity);
+    void Compact();
     
-    /// Remove the last element.
-    void Pop()
-    {
-        if (size_)
-            Resize(size_ - 1);
-    }
+    bool Contains(const T& value) const;
     
-    /// Insert an element at position.
-    void Insert(unsigned pos, const T& value)
-    {
-        if (pos > size_)
-            pos = size_;
-        
-        unsigned oldSize = size_;
-        Resize(size_ + 1);
-        MoveRange(pos + 1, pos, oldSize - pos);
-        Buffer()[pos] = value;
-    }
+    T& Front();
+    const T& Front() const;
+    T& Back();
+    const T& Back() const;
     
-    /// Insert another vector at position.
-    void Insert(unsigned pos, const PODVector<T>& vector)
-    {
-        if (pos > size_)
-            pos = size_;
-        
-        unsigned oldSize = size_;
-        Resize(size_ + vector.size_);
-        MoveRange(pos + vector.size_, pos, oldSize - pos);
-        CopyElements(Buffer() + pos, vector.Buffer(), vector.size_);
-    }
+    unsigned Size() const;
+    unsigned Capacity() const;
+    bool Empty() const;
     
-    /// Erase a range of elements.
-    void Erase(unsigned pos, unsigned length = 1)
-    {
-        // Return if the range is illegal
-        if (!length || pos + length > size_)
-            return;
-        
-        MoveRange(pos, pos + length, size_ - pos - length);
-        Resize(size_ - length);
-    }
-    
-    /// Erase an element if found.
-    bool Remove(const T& value)
-    {
-        Iterator i = Find(value);
-        if (i != End())
-        {
-            Erase(i);
-            return true;
-        }
-        else
-            return false;
-    }
-    
-    /// Clear the vector.
-    void Clear() { Resize(0); }
-    
-    /// Resize the vector.
-    void Resize(unsigned newSize)
-    {
-        if (newSize > capacity_)
-        {
-            if (!capacity_)
-                capacity_ = newSize;
-            else
-            {
-                while (capacity_ < newSize)
-                    capacity_ += (capacity_ + 1) >> 1;
-            }
-            
-            unsigned char* newBuffer = AllocateBuffer(capacity_ * sizeof(T));
-            // Move the data into the new buffer and delete the old
-            if (buffer_)
-            {
-                CopyElements(reinterpret_cast<T*>(newBuffer), Buffer(), size_);
-                delete[] buffer_;
-            }
-            buffer_ = newBuffer;
-        }
-        
-        size_ = newSize;
-    }
-    
-    /// Set new capacity.
-    void Reserve(unsigned newCapacity)
-    {
-        if (newCapacity < size_)
-            newCapacity = size_;
-        
-        if (newCapacity != capacity_)
-        {
-            unsigned char* newBuffer = 0;
-            capacity_ = newCapacity;
-            
-            if (capacity_)
-            {
-                newBuffer = AllocateBuffer(capacity_ * sizeof(T));
-                // Move the data into the new buffer
-                CopyElements(reinterpret_cast<T*>(newBuffer), Buffer(), size_);
-            }
-            
-            // Delete the old buffer
-            delete[] buffer_;
-            buffer_ = newBuffer;
-        }
-    }
-    
-    /// Reallocate so that no extra memory is used.
-    void Compact() { Reserve(size_); }
-    
-    /// Return whether contains a specific value.
-    bool Contains(const T& value) const { return Find(value) != End(); }
-    /// Return first element.
-    T& Front() { return Buffer()[0]; }
-    /// Return const first element.
-    const T& Front() const { return Buffer()[0]; }
-    /// Return last element.
-    T& Back() { assert(size_); return Buffer()[size_ - 1]; }
-    /// Return const last element.
-    const T& Back() const { assert(size_); return Buffer()[size_ - 1]; }
-    /// Return number of elements.
-    unsigned Size() const { return size_; }
-    /// Return capacity of vector.
-    unsigned Capacity() const { return capacity_; }
-    /// Return whether vector is empty.
-    bool Empty() const { return size_ == 0; }
-};
+    tolua_readonly tolua_property__no_prefix unsigned size;
+    tolua_readonly tolua_property__no_prefix unsigned capacity;
+    tolua_readonly tolua_property__no_prefix bool empty;
+};

+ 0 - 1
Extras/LuaScript/pkgs/ContainerLuaAPI.pkg

@@ -1,6 +1,5 @@
 $#define TOLUA_RELEASE
 
-$pfile "Container/Ptr.pkg"
 $pfile "Container/Str.pkg"
 $pfile "Container/Vector.pkg"
 

+ 3 - 2
Extras/LuaScript/pkgs/Core/Context.pkg

@@ -16,10 +16,11 @@ $#include "ResourceCache.h"
 $#include "Timer.h"
 $#include "UI.h"
 
-
-/// Urho3D execution context. Provides access to subsystems, object factories and attributes, and event receivers.
 class Context
 {
+    Object* GetEventSender() const;
+    EventHandler* GetEventHandler() const;
+    const String& GetTypeName(ShortStringHash type) const;
 };
 
 Context* GetContext();

+ 17 - 0
Extras/LuaScript/pkgs/Core/Object.pkg

@@ -3,9 +3,26 @@ $#include "Object.h"
 class Object : public RefCounted
 {
 public:
+    virtual ShortStringHash GetType() const;
+    
+    // virtual const String& GetTypeName() const;
     tolua_outside const char* ObjectGetTypeName @ GetTypeName() const;
+    
+    // void SendEvent(StringHash eventType);
     tolua_outside void ObjectSendEvent @ SendEvent(const char* eventName);
+
+    // void SendEvent(StringHash eventType, VariantMap& eventData);
     tolua_outside void ObjectSendEvent @ SendEvent(const char* eventName, VariantMap& eventData);
+    
+    Context* GetContext() const;
+    Object* GetEventSender() const;
+    EventHandler* GetEventHandler() const;
+    const String& GetCategory() const;
+    
+    tolua_readonly tolua_property__get_set Context* context;
+    tolua_readonly tolua_property__get_set Object* eventSender;
+    tolua_readonly tolua_property__get_set EventHandler* eventHandler;
+    tolua_readonly tolua_property__get_set String& category;
 };
 
 ${

+ 33 - 14
Extras/LuaScript/pkgs/Core/ProcessUtils.pkg

@@ -1,22 +1,41 @@
 $#include "ProcessUtils.h"
 
-/// Initialize the FPU to round-to-nearest, single precision mode.
-void InitFPU();
-/// Display an error dialog with the specified title and message.
+void ErrorDialog(const String& title, const String& message);
 void ErrorDialog(const char* title, const char* message);
-/// Exit the application with an error message to the console.
+
+void ErrorExit(const String& message = String::EMPTY, int exitCode = EXIT_FAILURE);
 void ErrorExit(const char* message, int exitCode = EXIT_FAILURE);
-/// Open a console window.
+
 void OpenConsoleWindow();
-/// Print ASCII text to the console with a newline appended. Uses printf() to allow printing into the MSVC output window.
+
+void PrintLine(const String& str, bool error = false);
 void PrintLine(const char* str, bool error = false);
-/// Return previously parsed arguments.
+
 const Vector<String>& GetArguments();
-/// Read input from the console window. Return empty if no input.
-String GetConsoleInput();
-/// Return the runtime platform identifier. Currently either "Windows", "Linux", "Mac OS X" or "Android".
-String GetPlatform();
-/// Return the number of physical CPU cores.
+
+// String GetConsoleInput();
+const char* GetConsoleInputCString @ GetConsoleInput();
+
+// String GetPlatform();
+const char* GetPlatformCString @ GetPlatform();
+
 unsigned GetNumPhysicalCPUs();
-/// Return the number of logical CPUs (different from physical if hyperthreading is used.)
-unsigned GetNumLogicalCPUs();
+unsigned GetNumLogicalCPUs();
+
+${
+
+static const char* GetConsoleInputCString()
+{
+    static String string;
+    string = GetConsoleInput();
+    return string.CString();
+}
+
+static const char* GetPlatformCString()
+{
+    static String string;
+    string = GetPlatform();
+    return string.CString();
+}
+
+$}

+ 13 - 28
Extras/LuaScript/pkgs/Core/StringUtils.pkg

@@ -1,58 +1,43 @@
 $#include "StringUtils.h"
 
-/// Parse a bool from a string. Check for the first non-empty character (converted to lowercase) being either 't', 'y' or '1'.
 bool ToBool(const String& source);
-/// Parse a bool from a C string. Check for the first non-empty character (converted to lowercase) being either 't', 'y' or '1'.
 bool ToBool(const char* source);
-/// Parse a float from a string.
+
 float ToFloat(const String& source);
-/// Parse a float from a C string.
 float ToFloat(const char* source);
-/// Parse an integer from a string.
+
 int ToInt(const String& source);
-/// Parse an integer from a C string.
 int ToInt(const char* source);
-/// Parse an unsigned integer from a string.
+
 unsigned ToUInt(const String& source);
-/// Parse an unsigned integer from a C string.
 unsigned ToUInt(const char* source);
-/// Parse a Color from a string.
+
 Color ToColor(const String& source);
-/// Parse a Color from a C string.
 Color ToColor(const char* source);
-/// Parse an IntRect from a string.
+
 IntRect ToIntRect(const String& source);
-/// Parse an IntRect from a C string.
 IntRect ToIntRect(const char* source);
-/// Parse an IntVector2 from a string.
+
 IntVector2 ToIntVector2(const String& source);
-/// Parse an IntVector2 from a C string.
 IntVector2 ToIntVector2(const char* source);
-/// Parse a Quaternion from a string. If only 3 components specified, convert Euler angles (degrees) to quaternion.
+
 Quaternion ToQuaternion(const String& source);
-/// Parse a Quaternion from a C string. If only 3 components specified, convert Euler angles (degrees) to quaternion.
 Quaternion ToQuaternion(const char* source);
-/// Parse a Rect from a string.
+
 Rect ToRect(const String& source);
-/// Parse a Rect from a C string.
 Rect ToRect(const char* source);
-/// Parse a Vector2 from a string.
+
 Vector2 ToVector2(const String& source);
-/// Parse a Vector2 from a C string.
 Vector2 ToVector2(const char* source);
-/// Parse a Vector3 from a string.
+
 Vector3 ToVector3(const String& source);
-/// Parse a Vector3 from a C string.
 Vector3 ToVector3(const char* source);
-/// Parse a Vector4 from a string.
+
 Vector4 ToVector4(const String& source, bool allowMissingCoords = false);
-/// Parse a Vector4 from a C string.
 Vector4 ToVector4(const char* source, bool allowMissingCoords = false);
-/// Convert a pointer to string (returns hexadecimal.)
+
 String ToString(void* value);
-/// Convert an unsigned integer to string as hexadecimal.
 String ToStringHex(unsigned value);
-/// Return whether a char is an alphabet letter.
+
 bool IsAlpha(unsigned ch);
-/// Return whether a char is a digit.
 bool IsDigit(unsigned ch);

+ 3 - 9
Extras/LuaScript/pkgs/Core/Timer.pkg

@@ -1,25 +1,19 @@
 $#include "Timer.h"
 
-class Timer
-{
-public:
-    unsigned GetMSec(bool reset);
-    void Reset();
-};
 
 class Time : public Object
 {
-public:
-    // Methods:
     unsigned GetFrameNumber() const;
     float GetTimeStep() const;
+    unsigned GetTimerPeriod() const;
     float GetElapsedTime();
     
     static unsigned GetSystemTime();
     static String GetTimeStamp();
+    static void Sleep(unsigned mSec);
     
-    // Properties:
     tolua_readonly tolua_property__get_set unsigned frameNumber;
     tolua_readonly tolua_property__get_set float timeStep;
+    tolua_readonly tolua_property__get_set unsigned timerPeriod;
     tolua_readonly tolua_property__get_set float elapsedTime;
 };

+ 22 - 119
Extras/LuaScript/pkgs/Core/Variant.pkg

@@ -1,6 +1,5 @@
 $#include "Variant.h"
 
-/// Variant's supported types.
 enum VariantType
 {
     VAR_NONE = 0,
@@ -24,213 +23,117 @@ enum VariantType
     MAX_VAR_TYPES
 };
 
-/// Typed resource reference.
 struct ResourceRef
 {
-    /// Construct.
     ResourceRef();
 
-    /// Construct with type only and empty id.
     ResourceRef(ShortStringHash type);
 
-    /// Construct with type and id.
     ResourceRef(ShortStringHash type, StringHash id);
 
-    // Construct from another ResourceRef.
     ResourceRef(const ResourceRef& rhs);
 
-    /// Object type.
     ShortStringHash type_ @ type;
     StringHash id_ @ id;
 
-    /// Test for equality with another reference.
     bool operator == (const ResourceRef& rhs) const;
 };
 
-/// %List of typed resource references.
 struct ResourceRefList
 {
-    /// Construct.
     ResourceRefList();
-
-    /// Construct with type only.
     ResourceRefList(ShortStringHash type);
 
-    /// Object type.
+
     ShortStringHash type_ @ type;
 
-    /// Test for equality with another reference list.
     bool operator == (const ResourceRefList& rhs) const;
 };
 
-/// Variable that supports a fixed set of types.
+
 class Variant
 {
 public:
-    /// Construct empty.
     Variant();
-
-    /// Construct from integer.
     Variant(int value);
-
-    /// Construct from unsigned integer.
     Variant(unsigned value);
-
-    /// Construct from a string hash (convert to integer).
     Variant(const StringHash& value);
-
-    /// Construct from a short string hash (convert to integer.)
     Variant(const ShortStringHash& value);
-
-    /// Construct from a bool.
     Variant(bool value);
-
-    /// Construct from a float.
     Variant(float value);
-
-    /// Construct from a Vector2.
     Variant(const Vector2& value);
-
-    /// Construct from a Vector3.
     Variant(const Vector3& value);
-
-    /// Construct from a Vector4.
     Variant(const Vector4& value);
-
-    /// Construct from a quaternion.
     Variant(const Quaternion& value);
-
-    /// Construct from a color.
     Variant(const Color& value);
-
-    /// Construct from a string.
     Variant(const String& value);
-
-    /// Construct from a C string.
     Variant(const char* value);
-
-    /// Construct from a pointer.
     Variant(void* value);
-
-    /// Construct from a resource reference.
     Variant(const ResourceRef& value);
-
-    /// Construct from a resource reference list.
     Variant(const ResourceRefList& value);
-
-    /// Construct from an integer rect.
     Variant(const IntRect& value);
-
-    /// Construct from an IntVector2.
     Variant(const IntVector2& value);
-
-    /// Construct from type and value.
     Variant(const String& type, const String& value);
-
-    /// Construct from type and value.
     Variant(VariantType type, const String& value) ;
-
-    /// Construct from type and value.
     Variant(VariantType type, const char* value);
-
-    /// Copy-construct from another variant.
     Variant(const Variant& value);
-
-    /// Destruct.
     ~Variant();
 
-    /// Reset to empty.
     void Clear();
-
-    /// Test for equality with another variant.
     bool operator == (const Variant& rhs) const;
-    /// Test for equality with an integer. To return true, both the type and value must match.
     bool operator == (int rhs) const;
-    /// Test for equality with an unsigned integer. To return true, both the type and value must match.
     bool operator == (unsigned rhs) const;
-    /// Test for equality with a bool. To return true, both the type and value must match.
     bool operator == (bool rhs) const;
-    /// Test for equality with a float. To return true, both the type and value must match.
     bool operator == (float rhs) const;
-    /// Test for equality with a Vector2. To return true, both the type and value must match.
     bool operator == (const Vector2& rhs);
-    /// Test for equality with a Vector3. To return true, both the type and value must match.
     bool operator == (const Vector3& rhs) const;
-    /// Test for equality with a Vector4. To return true, both the type and value must match.
     bool operator == (const Vector4& rhs) const;
-    /// Test for equality with a quaternion. To return true, both the type and value must match.
     bool operator == (const Quaternion& rhs) const;
-    /// Test for equality with a color. To return true, both the type and value must match.
     bool operator == (const Color& rhs) const;
-    /// Test for equality with a string. To return true, both the type and value must match.
     bool operator == (const String& rhs) const;
-    /// Test for equality with a pointer. To return true, both the type and value must match.
     bool operator == (void* rhs) const;
-    /// Test for equality with a resource reference. To return true, both the type and value must match.
     bool operator == (const ResourceRef& rhs) const;
-    /// Test for equality with a resource reference list. To return true, both the type and value must match.
     bool operator == (const ResourceRefList& rhs) const;
-    /// Test for equality with an integer rect. To return true, both the type and value must match.
     bool operator == (const IntRect& rhs) const;
-    /// Test for equality with an IntVector2. To return true, both the type and value must match.
     bool operator == (const IntVector2& rhs) const;
-    /// Test for equality with a StringHash. To return true, both the type and value must match.
     bool operator == (const StringHash& rhs) const;
-    /// Test for equality with a ShortStringHash. To return true, both the type and value must match.
     bool operator == (const ShortStringHash& rhs) const;
 
-    /// Return int or zero on type mismatch.
     int GetInt() const;
-    /// Return unsigned int or zero on type mismatch.
     int GetUInt() const;
-    /// Return StringHash or zero on type mismatch.
     StringHash GetStringHash();
-    /// Return ShortStringHash or zero on type mismatch.
     ShortStringHash GetShortStringHash();
-    /// Return bool or false on type mismatch.
     bool GetBool() const;
-    /// Return float or zero on type mismatch.
     float GetFloat() const;
-    /// Return Vector2 or zero on type mismatch.
     const Vector2& GetVector2() const;
-    /// Return Vector3 or zero on type mismatch.
     const Vector3& GetVector3() const;
-    /// Return Vector4 or zero on type mismatch.
     const Vector4& GetVector4() const;
-    /// Return quaternion or identity on type mismatch.
     const Quaternion& GetQuaternion() const;
-    /// Return color or default on type mismatch.
     const Color& GetColor() const;
-    /// Return string or empty on type mismatch.
     const String& GetString() const;
-    /// Return pointer or null on type mismatch.
     void* GetPtr() const;
-    /// Return a resource reference or empty on type mismatch.
     const ResourceRef& GetResourceRef() const;
-    /// Return a resource reference list or empty on type mismatch.
     const ResourceRefList& GetResourceRefList() const;
-    /// Return an integer rect or empty on type mismatch.
     const IntRect& GetIntRect() const;
-    /// Return an IntVector2 or empty on type mismatch.
     const IntVector2& GetIntVector2() const;
 
-    /// Return value's type.
     VariantType GetType() const;
-    /// Return value's type name.
     String GetTypeName() const;
-    /// Convert value to string. Pointers are returned as null, and VariantBuffer or VariantMap are not supported and return empty.
     String ToString() const;
-    /// Return true when the variant value is considered zero according to its actual type.
     bool IsZero() const;
-    /// Return true when the variant is empty (i.e. not initialized yet).
     bool IsEmpty() const;
+    
+    tolua_readonly tolua_property__get_set VariantType type;
+    tolua_readonly tolua_property__get_set String typeName;
+    tolua_readonly tolua_property__is_set bool zero;
+    tolua_readonly tolua_property__is_set bool empty;
 };
 
 class VariantMap
 {
 public:
     VariantMap();
-
+    
     tolua_outside void VariantMapSetInt @ SetInt(const char* key, int value);
     tolua_outside void VariantMapSetBool @ SetBool(const char* key, bool value);
     tolua_outside void VariantMapSetFloat @ SetFloat(const char* key, float value);
@@ -353,37 +256,37 @@ void VariantMapSetIntVector2(VariantMap* vmap, const char* key, const IntVector2
 
 void VariantMapSetCamera(VariantMap* vmap, const char* key, Camera* pointer)
 {
-	(*vmap)[ShortStringHash(key)] = (void*)pointer;
+    (*vmap)[ShortStringHash(key)] = (void*)pointer;
 }
 
 void VariantMapSetConnection(VariantMap* vmap, const char* key, Connection* pointer)
 {
-	(*vmap)[ShortStringHash(key)] = (void*)pointer;
+    (*vmap)[ShortStringHash(key)] = (void*)pointer;
 }
 
 void VariantMapSetNode(VariantMap* vmap, const char* key, Node* pointer)
 {
-	(*vmap)[ShortStringHash(key)] = (void*)pointer;
+    (*vmap)[ShortStringHash(key)] = (void*)pointer;
 }
 
 void VariantMapSetPhysicsWorld(VariantMap* vmap, const char* key, PhysicsWorld* pointer)
 {
-	(*vmap)[ShortStringHash(key)] = (void*)pointer;
+    (*vmap)[ShortStringHash(key)] = (void*)pointer;
 }
 
 void VariantMapSetRigidBody(VariantMap* vmap, const char* key, RigidBody* pointer)
 {
-	(*vmap)[ShortStringHash(key)] = (void*)pointer;
+    (*vmap)[ShortStringHash(key)] = (void*)pointer;
 }
 
 void VariantMapSetScene(VariantMap* vmap, const char* key, Scene* pointer)
 {
-	(*vmap)[ShortStringHash(key)] = (void*)pointer;
+    (*vmap)[ShortStringHash(key)] = (void*)pointer;
 }
 
 void VariantMapSetUIElement(VariantMap* vmap, const char* key, UIElement* pointer)
 {
-	(*vmap)[ShortStringHash(key)] = (void*)pointer;
+    (*vmap)[ShortStringHash(key)] = (void*)pointer;
 }
 
 const Variant& FindVariant(const VariantMap* vmap, const char* key)
@@ -464,37 +367,37 @@ const IntVector2& VariantMapGetIntVector2(const VariantMap* vmap, const char* ke
 
 Camera* VariantMapGetCamera(const VariantMap* vmap, const char* key)
 {
-	return (Camera*)FindVariant(vmap, key).GetPtr();
+    return (Camera*)FindVariant(vmap, key).GetPtr();
 }
 
 Connection* VariantMapGetConnection(const VariantMap* vmap, const char* key)
 {
-	return (Connection*)FindVariant(vmap, key).GetPtr();
+    return (Connection*)FindVariant(vmap, key).GetPtr();
 }
 
 Node* VariantMapGetNode(const VariantMap* vmap, const char* key)
 {
-	return (Node*)FindVariant(vmap, key).GetPtr();
+    return (Node*)FindVariant(vmap, key).GetPtr();
 }
 
 PhysicsWorld* VariantMapGetPhysicsWorld(const VariantMap* vmap, const char* key)
 {
-	return (PhysicsWorld*)FindVariant(vmap, key).GetPtr();
+    return (PhysicsWorld*)FindVariant(vmap, key).GetPtr();
 }
 
 RigidBody* VariantMapGetRigidBody(const VariantMap* vmap, const char* key)
 {
-	return (RigidBody*)FindVariant(vmap, key).GetPtr();
+    return (RigidBody*)FindVariant(vmap, key).GetPtr();
 }
 
 Scene* VariantMapGetScene(const VariantMap* vmap, const char* key)
 {
-	return (Scene*)FindVariant(vmap, key).GetPtr();
+    return (Scene*)FindVariant(vmap, key).GetPtr();
 }
 
 UIElement* VariantMapGetUIElement(const VariantMap* vmap, const char* key)
 {
-	return (UIElement*)FindVariant(vmap, key).GetPtr();
+    return (UIElement*)FindVariant(vmap, key).GetPtr();
 }
 
 $}

+ 0 - 3
Extras/LuaScript/pkgs/Graphics/Drawable.pkg

@@ -47,7 +47,6 @@ class Drawable : public Component
     bool GetCastShadows() const;
     bool IsOccluder() const;
     bool IsOccludee() const;
-    const Vector<SourceBatch>& GetBatches() const;
     
     void SetZone(Zone* zone, bool temporary = false);
     void SetSortValue(float value);
@@ -69,8 +68,6 @@ class Drawable : public Component
     bool IsInView(unsigned frameNumber) const;
     bool IsInView(const FrameInfo& frame, bool mainView = true) const;
     bool HasBasePass(unsigned batchIndex) const;
-    const PODVector<Light*>& GetLights() const;
-    const PODVector<Light*>& GetVertexLights() const;
     Light* GetFirstLight() const;
     float GetMinZ() const;
     float GetMaxZ() const;

+ 2 - 1
Extras/LuaScript/pkgs/Graphics/StaticModel.pkg

@@ -16,12 +16,13 @@ class StaticModel : public Drawable
     Model* GetModel() const;
     const BoundingBox& GetBoundingBox() const;
     unsigned GetNumGeometries() const;
-    Material* GetMaterial(unsigned index) const;
+    Material* GetMaterial(unsigned index = 0) const;
     unsigned GetOcclusionLodLevel() const;
     bool IsInside(const Vector3& point) const;
     bool IsInsideLocal(const Vector3& point) const;
     
     tolua_property__get_set Model* model;
+    tolua_property__get_set Material* material;
     tolua_readonly tolua_property__get_set BoundingBox& boundingBox;
     tolua_readonly tolua_property__get_set unsigned numGeometries;
     tolua_property__get_set unsigned occlusionLodLevel;

+ 0 - 1
Extras/LuaScript/pkgs/IO/Deserializer.pkg

@@ -34,7 +34,6 @@ class Deserializer
     String ReadFileID();
     StringHash ReadStringHash();
     ShortStringHash ReadShortStringHash();
-    PODVector<unsigned char> ReadBuffer();
     ResourceRef ReadResourceRef();
     ResourceRefList ReadResourceRefList();
     Variant ReadVariant();

+ 0 - 1
Extras/LuaScript/pkgs/IO/Serializer.pkg

@@ -27,7 +27,6 @@ class Serializer
     bool WriteFileID(const String& value);
     bool WriteStringHash(const StringHash& value);
     bool WriteShortStringHash(const ShortStringHash& value);
-    bool WriteBuffer(const PODVector<unsigned char>& buffer);
     bool WriteResourceRef(const ResourceRef& value);
     bool WriteResourceRefList(const ResourceRefList& value);
     bool WriteVariant(const Variant& value);

+ 14 - 93
Extras/LuaScript/pkgs/Math/Color.pkg

@@ -1,115 +1,36 @@
 $#include "Color.h"
 
-/// RGBA color.
 class Color
 {
-public:
-    /// Construct with default values (opaque white.)
-    Color() :
-        r_(1.0f),
-        g_(1.0f),
-        b_(1.0f),
-        a_(1.0f)
-    {
-    }
+    Color();
+    Color(const Color& color);
+    Color(const Color& color, float a);
+    Color(float r, float g, float b);
+    Color(float r, float g, float b, float a);
     
-    /// Copy-construct from another color.
-    Color(const Color& color) :
-        r_(color.r_),
-        g_(color.g_),
-        b_(color.b_),
-        a_(color.a_)
-    {
-    }
+    bool operator == (const Color& rhs) const;
+    Color operator * (float rhs) const;
+    Color operator + (const Color& rhs);
     
-    /// Construct from another color and modify the alpha.
-    Color(const Color& color, float a) :
-        r_(color.r_),
-        g_(color.g_),
-        b_(color.b_),
-        a_(a)
-    {
-    }
+    Vector3 RGBValues() const;
+    float Intensity() const;
     
-    /// Construct from RGB values and set alpha fully opaque.
-    Color(float r, float g, float b) :
-        r_(r),
-        g_(g),
-        b_(b),
-        a_(1.0f)
-    {
-    }
+    Color Lerp(const Color& rhs, float t) const;
+    unsigned ToUInt() const;
     
-    /// Construct from RGBA values.
-    Color(float r, float g, float b, float a) :
-        r_(r),
-        g_(g),
-        b_(b),
-        a_(a)
-    {
-    }
-    /// Test for equality with another color.
-    bool operator == (const Color& rhs) const { return Equals(r_, rhs.r_) && Equals(g_, rhs.g_) && Equals(b_, rhs.b_) && Equals(a_, rhs.a_); }
-    /// Multiply with a scalar.
-    Color operator * (float rhs) const { return Color(r_ * rhs, g_ * rhs, b_ * rhs, a_ * rhs); }
-    /// Add a color.
-    Color operator + (const Color& rhs) const { return Color(r_ + rhs.r_, g_ + rhs.g_, b_ + rhs.b_, a_ + rhs.a_); }
-    
-    
-        
-    /// Return RGB values as a Vector3.
-    Vector3 RGBValues() const { return Vector3(r_, g_, b_); }
-    /// Return approximate intensity.
-    float Intensity() const { return RGBValues().DotProduct(Vector3(0.333f, 0.333f, 0.333f)); }
-    
-    /// Linear interpolation with another color.
-    Color Lerp(const Color& rhs, float t) const
-    {
-        float invT = 1.0f - t;
-        return Color(
-            r_ * invT + rhs.r_ * t,
-            g_ * invT + rhs.g_ * t,
-            b_ * invT + rhs.b_ * t,
-            a_ * invT + rhs.a_ * t
-        );
-    }
-    
-    /// Return color packed to a 32-bit integer. Components are clamped to [0, 1] range.
-    unsigned ToUInt() const
-    {
-        unsigned r = Clamp(((int)(r_ * 255.0f)), 0, 255);
-        unsigned g = Clamp(((int)(g_ * 255.0f)), 0, 255);
-        unsigned b = Clamp(((int)(b_ * 255.0f)), 0, 255);
-        unsigned a = Clamp(((int)(a_ * 255.0f)), 0, 255);
-        return (a << 24) | (b << 16) | (g << 8) | r;
-    }
-    
-    /// Return as a four-dimensional vector.
-    Vector4 ToVector4() const { return Vector4(r_, g_, b_, a_); }
-    
-    /// Return as string.
+    Vector4 ToVector4() const;
     String ToString() const;
-    /// Red value.
+    
     float r_ @ r;
-    /// Green value.
     float g_ @ g;
-    /// Blue value.
     float b_ @ b;
-    /// Alpha value.
     float a_ @ a;
     
-    /// Opaque white color.
     static const Color WHITE;
-    /// Opaque yellow color.
     static const Color YELLOW;
-    /// Opaque red color.
     static const Color RED;
-    /// Opaque green color.
     static const Color GREEN;
-    /// Opaque green color.
     static const Color BLUE;
-    /// Opaque black color.
     static const Color BLACK;
-    /// Transparent color (black with no alpha).
     static const Color TRANSPARENT;
 };

+ 7 - 107
Extras/LuaScript/pkgs/Math/Frustum.pkg

@@ -1,6 +1,5 @@
 $#include "Frustum.h"
 
-/// Frustum planes.
 enum FrustumPlane
 {
     PLANE_NEAR = 0,
@@ -14,126 +13,27 @@ enum FrustumPlane
 static const unsigned NUM_FRUSTUM_PLANES;
 static const unsigned NUM_FRUSTUM_VERTICES;
 
-/// Convex constructed of 6 planes.
 class Frustum
 {
-public:
-    /// Construct undefined.
     Frustum();
-    /// Copy-construct from another frustum.
     Frustum(const Frustum& frustum);
-    
-    /// Define with projection parameters and a transform matrix.
+
     void Define(float fov, float aspectRatio, float zoom, float nearZ, float farZ, const Matrix3x4& transform = Matrix3x4::IDENTITY);
-    /// Define with near and far dimension vectors and a transform matrix.
     void Define(const Vector3& near, const Vector3& far, const Matrix3x4& transform = Matrix3x4::IDENTITY);
-    /// Define with a bounding box and a transform matrix.
     void Define(const BoundingBox& box, const Matrix3x4& transform = Matrix3x4::IDENTITY);
-    /// Define with orthographic projection parameters and a transform matrix.
     void DefineOrtho(float orthoSize, float aspectRatio, float zoom, float nearZ, float farZ, const Matrix3x4& transform = Matrix3x4::IDENTITY);
-    /// Transform by a 3x3 matrix.
     void Transform(const Matrix3& transform);
-    /// Transform by a 3x4 matrix.
     void Transform(const Matrix3x4& transform);
     
-    /// Test if a point is inside or outside.
-    Intersection IsInside(const Vector3& point) const
-    {
-        for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
-        {
-            if (planes_[i].Distance(point) < 0.0f)
-                return OUTSIDE;
-        }
-        
-        return INSIDE;
-    }
-    
-    /// Test if a sphere is inside, outside or intersects.
-    Intersection IsInside(const Sphere& sphere) const
-    {
-        bool allInside = true;
-        for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
-        {
-            float dist = planes_[i].Distance(sphere.center_);
-            if (dist < -sphere.radius_)
-                return OUTSIDE;
-            else if (dist < sphere.radius_)
-                allInside = false;
-        }
-        
-        return allInside ? INSIDE : INTERSECTS;
-    }
-    
-    /// Test if a sphere if (partially) inside or outside.
-    Intersection IsInsideFast(const Sphere& sphere) const
-    {
-        for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
-        {
-            if (planes_[i].Distance(sphere.center_) < -sphere.radius_)
-                return OUTSIDE;
-        }
-        
-        return INSIDE;
-    }
+    Intersection IsInside(const Vector3& point) const;
+    Intersection IsInside(const Sphere& sphere) const;
+    Intersection IsInsideFast(const Sphere& sphere) const;
+    Intersection IsInside(const BoundingBox& box) const;
+    Intersection IsInsideFast(const BoundingBox& box) const;
+    float Distance(const Vector3& point) const;
     
-    /// Test if a bounding box is inside, outside or intersects.
-    Intersection IsInside(const BoundingBox& box) const
-    {
-        Vector3 center = box.Center();
-        Vector3 edge = center - box.min_;
-        bool allInside = true;
-        
-        for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
-        {
-            const Plane& plane = planes_[i];
-            float dist = plane.normal_.DotProduct(center) - plane.intercept_;
-            float absDist = plane.absNormal_.DotProduct(edge);
-            
-            if (dist < -absDist)
-                return OUTSIDE;
-            else if (dist < absDist)
-                allInside = false;
-        }
-        
-        return allInside ? INSIDE : INTERSECTS;
-    }
-    
-    /// Test if a bounding box is (partially) inside or outside.
-    Intersection IsInsideFast(const BoundingBox& box) const
-    {
-        Vector3 center = box.Center();
-        Vector3 edge = center - box.min_;
-        
-        for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
-        {
-            const Plane& plane = planes_[i];
-            float dist = plane.normal_.DotProduct(center) - plane.intercept_;
-            float absDist = plane.absNormal_.DotProduct(edge);
-            
-            if (dist < -absDist)
-                return OUTSIDE;
-        }
-        
-        return INSIDE;
-    }
-    
-    /// Return distance of a point to the frustum, or 0 if inside.
-    float Distance(const Vector3& point) const
-    {
-        float distance = 0.0f;
-        for (unsigned i = 0; i < NUM_FRUSTUM_PLANES; ++i)
-            distance = Max(-planes_[i].Distance(point), distance);
-        
-        return distance;
-    }
-    
-    /// Return transformed by a 3x3 matrix.
     Frustum Transformed(const Matrix3& transform) const;
-    /// Return transformed by a 3x4 matrix.
     Frustum Transformed(const Matrix3x4& transform) const;
-    /// Return projected by a 4x4 projection matrix.
     Rect Projected(const Matrix4& transform) const;
-    
-    /// Update the planes. Called internally.
     void UpdatePlanes();
 };

+ 15 - 217
Extras/LuaScript/pkgs/Math/Matrix3.pkg

@@ -1,208 +1,28 @@
 $#include "Matrix3.h"
 
-/// 3x3 matrix for rotation and scaling.
 class Matrix3
 {
-public:
-    /// Construct undefined.
-    Matrix3()
-    {
-    }
-    
-    /// Copy-construct from another matrix.
-    Matrix3(const Matrix3& matrix) :
-        m00_(matrix.m00_),
-        m01_(matrix.m01_),
-        m02_(matrix.m02_),
-        m10_(matrix.m10_),
-        m11_(matrix.m11_),
-        m12_(matrix.m12_),
-        m20_(matrix.m20_),
-        m21_(matrix.m21_),
-        m22_(matrix.m22_)
-    {
-    }
-    
-    /// Construct from values.
+    Matrix3();
+    Matrix3(const Matrix3& matrix);
     Matrix3(float v00, float v01, float v02,
             float v10, float v11, float v12,
-            float v20, float v21, float v22) :
-        m00_(v00),
-        m01_(v01),
-        m02_(v02),
-        m10_(v10),
-        m11_(v11),
-        m12_(v12),
-        m20_(v20),
-        m21_(v21),
-        m22_(v22)
-    {
-    }
-    
-    
-    /// Test for equality with another matrix without epsilon.
-    bool operator == (const Matrix3& rhs) const
-    {
-        const float* leftData = Data();
-        const float* rightData = rhs.Data();
-        
-        for (unsigned i = 0; i < 9; ++i)
-        {
-            if (leftData[i] != rightData[i])
-                return false;
-        }
-        
-        return true;
-    }
-    
-    /// Multiply a Vector3.
-    Vector3 operator * (const Vector3& rhs) const
-    {
-        return Vector3(
-            m00_ * rhs.x_ + m01_ * rhs.y_ + m02_ * rhs.z_,
-            m10_ * rhs.x_ + m11_ * rhs.y_ + m12_ * rhs.z_,
-            m20_ * rhs.x_ + m21_ * rhs.y_ + m22_ * rhs.z_
-        );
-    }
-    
-    /// Add a matrix.
-    Matrix3 operator + (const Matrix3& rhs) const
-    {
-        return Matrix3(
-            m00_ + rhs.m00_,
-            m01_ + rhs.m01_,
-            m02_ + rhs.m02_,
-            m10_ + rhs.m10_,
-            m11_ + rhs.m11_,
-            m12_ + rhs.m12_,
-            m20_ + rhs.m20_,
-            m21_ + rhs.m21_,
-            m22_ + rhs.m22_
-        );
-    }
-    
-    /// Subtract a matrix.
-    Matrix3 operator - (const Matrix3& rhs) const
-    {
-        return Matrix3(
-            m00_ - rhs.m00_,
-            m01_ - rhs.m01_,
-            m02_ - rhs.m02_,
-            m10_ - rhs.m10_,
-            m11_ - rhs.m11_,
-            m12_ - rhs.m12_,
-            m20_ - rhs.m20_,
-            m21_ - rhs.m21_,
-            m22_ - rhs.m22_
-        );
-    }
+            float v20, float v21, float v22);
     
-    /// Multiply with a scalar.
-    Matrix3 operator * (float rhs) const
-    {
-        return Matrix3(
-            m00_ * rhs,
-            m01_ * rhs,
-            m02_ * rhs,
-            m10_ * rhs,
-            m11_ * rhs,
-            m12_ * rhs,
-            m20_ * rhs,
-            m21_ * rhs,
-            m22_ * rhs
-        );
-    }
+    bool operator == (const Matrix3& rhs) const;
     
-    /// Multiply a matrix.
-    Matrix3 operator * (const Matrix3& rhs) const
-    {
-        return Matrix3(
-            m00_ * rhs.m00_ + m01_ * rhs.m10_ + m02_ * rhs.m20_,
-            m00_ * rhs.m01_ + m01_ * rhs.m11_ + m02_ * rhs.m21_,
-            m00_ * rhs.m02_ + m01_ * rhs.m12_ + m02_ * rhs.m22_,
-            m10_ * rhs.m00_ + m11_ * rhs.m10_ + m12_ * rhs.m20_,
-            m10_ * rhs.m01_ + m11_ * rhs.m11_ + m12_ * rhs.m21_,
-            m10_ * rhs.m02_ + m11_ * rhs.m12_ + m12_ * rhs.m22_,
-            m20_ * rhs.m00_ + m21_ * rhs.m10_ + m22_ * rhs.m20_,
-            m20_ * rhs.m01_ + m21_ * rhs.m11_ + m22_ * rhs.m21_,
-            m20_ * rhs.m02_ + m21_ * rhs.m12_ + m22_ * rhs.m22_
-        );
-    }
+    Vector3 operator * (const Vector3& rhs) const;
+    Matrix3 operator + (const Matrix3& rhs) const;
+    Matrix3 operator - (const Matrix3& rhs) const;
+    Matrix3 operator * (float rhs) const;
+    Matrix3 operator * (const Matrix3& rhs) const;
     
-    /// Set scaling elements.
-    void SetScale(const Vector3& scale)
-    {
-        m00_ = scale.x_;
-        m11_ = scale.y_;
-        m22_ = scale.z_;
-    }
+    void SetScale(const Vector3& scale);
+    void SetScale(float scale);
     
-    /// Set uniform scaling elements.
-    void SetScale(float scale)
-    {
-        m00_ = scale;
-        m11_ = scale;
-        m22_ = scale;
-    }
-    
-    /// Return the scaling part.
-    Vector3 Scale() const
-    {
-        return Vector3(
-            sqrtf(m00_ * m00_ + m10_ * m10_ + m20_ * m20_),
-            sqrtf(m01_ * m01_ + m11_ * m11_ + m21_ * m21_),
-            sqrtf(m02_ * m02_ + m12_ * m12_ + m22_ * m22_)
-        );
-    }
-    
-    /// Return transpose.
-    Matrix3 Transpose() const
-    {
-        return Matrix3(
-            m00_,
-            m10_,
-            m20_,
-            m01_,
-            m11_,
-            m21_,
-            m02_,
-            m12_,
-            m22_
-        );
-    }
-    
-    /// Return scaled by a vector.
-    Matrix3 Scaled(const Vector3& scale) const
-    {
-        return Matrix3(
-            m00_ * scale.x_,
-            m01_ * scale.y_,
-            m02_ * scale.z_,
-            m10_ * scale.x_,
-            m11_ * scale.y_,
-            m12_ * scale.z_,
-            m20_ * scale.x_,
-            m21_ * scale.y_,
-            m22_ * scale.z_
-        );
-    }
-    
-    /// Test for equality with another matrix with epsilon.
-    bool Equals(const Matrix3& rhs) const
-    {
-        const float* leftData = Data();
-        const float* rightData = rhs.Data();
-        
-        for (unsigned i = 0; i < 9; ++i)
-        {
-            if (!Urho3D::Equals(leftData[i], rightData[i]))
-                return false;
-        }
-        
-        return true;
-    }
-    
-    /// Return inverse.
+    Vector3 Scale() const;
+    Matrix3 Transpose() const;
+    Matrix3 Scaled(const Vector3& scale) const;
+    bool Equals(const Matrix3& rhs) const;
     Matrix3 Inverse() const;
     
     float m00_ @ m00;
@@ -215,28 +35,6 @@ public:
     float m21_ @ m21;
     float m22_ @ m22;
     
-    /// Bulk transpose matrices.
-    static void BulkTranspose(float* dest, const float* src, unsigned count)
-    {
-        for (unsigned i = 0; i < count; ++i)
-        {
-            dest[0] = src[0];
-            dest[1] = src[3];
-            dest[2] = src[6];
-            dest[3] = src[1];
-            dest[4] = src[4];
-            dest[5] = src[7];
-            dest[6] = src[2];
-            dest[7] = src[5];
-            dest[8] = src[8];
-            
-            dest += 9;
-            src += 9;
-        }
-    }
-    
-    /// Zero matrix.
     static const Matrix3 ZERO;
-    /// Identity matrix.
     static const Matrix3 IDENTITY;
 };

+ 24 - 312
Extras/LuaScript/pkgs/Math/Matrix3x4.pkg

@@ -1,330 +1,44 @@
 $#include "Matrix3x4.h"
 
-/// 3x4 matrix for scene node transform calculations.
 class Matrix3x4
 {
-public:
-    /// Construct undefined.
-    Matrix3x4()
-    {
-    }
-    
-    /// Copy-construct from another matrix.
-    Matrix3x4(const Matrix3x4& matrix) :
-        m00_(matrix.m00_),
-        m01_(matrix.m01_),
-        m02_(matrix.m02_),
-        m03_(matrix.m03_),
-        m10_(matrix.m10_),
-        m11_(matrix.m11_),
-        m12_(matrix.m12_),
-        m13_(matrix.m13_),
-        m20_(matrix.m20_),
-        m21_(matrix.m21_),
-        m22_(matrix.m22_),
-        m23_(matrix.m23_)
-    {
-    }
-    
-    /// Copy-construct from a 3x3 matrix and set the extra elements to identity.
-    Matrix3x4(const Matrix3& matrix) :
-        m00_(matrix.m00_),
-        m01_(matrix.m01_),
-        m02_(matrix.m02_),
-        m03_(0.0f),
-        m10_(matrix.m10_),
-        m11_(matrix.m11_),
-        m12_(matrix.m12_),
-        m13_(0.0f),
-        m20_(matrix.m20_),
-        m21_(matrix.m21_),
-        m22_(matrix.m22_),
-        m23_(0.0f)
-    {
-    }
-    
-    /// Copy-construct from a 4x4 matrix which is assumed to contain no projection.
-    Matrix3x4(const Matrix4& matrix) :
-        m00_(matrix.m00_),
-        m01_(matrix.m01_),
-        m02_(matrix.m02_),
-        m03_(matrix.m03_),
-        m10_(matrix.m10_),
-        m11_(matrix.m11_),
-        m12_(matrix.m12_),
-        m13_(matrix.m13_),
-        m20_(matrix.m20_),
-        m21_(matrix.m21_),
-        m22_(matrix.m22_),
-        m23_(matrix.m23_)
-    {
-    }
-    
-    // Construct from values.
+    Matrix3x4();
+    Matrix3x4(const Matrix3x4& matrix);
+    Matrix3x4(const Matrix3& matrix);
+    Matrix3x4(const Matrix4& matrix);
     Matrix3x4(float v00, float v01, float v02, float v03,
             float v10, float v11, float v12, float v13,
-            float v20, float v21, float v22, float v23) :
-        m00_(v00),
-        m01_(v01),
-        m02_(v02),
-        m03_(v03),
-        m10_(v10),
-        m11_(v11),
-        m12_(v12),
-        m13_(v13),
-        m20_(v20),
-        m21_(v21),
-        m22_(v22),
-        m23_(v23)
-    {
-    }
-    
-    /// Construct from translation, rotation and uniform scale.
+            float v20, float v21, float v22, float v23);
     Matrix3x4(const Vector3& translation, const Quaternion& rotation, float scale);
-    /// Construct from translation, rotation and nonuniform scale.
     Matrix3x4(const Vector3& translation, const Quaternion& rotation, const Vector3& scale);
     
-    /// Test for equality with another matrix without epsilon.
-    bool operator == (const Matrix3x4& rhs) const
-    {
-        const float* leftData = Data();
-        const float* rightData = rhs.Data();
-        
-        for (unsigned i = 0; i < 12; ++i)
-        {
-            if (leftData[i] != rightData[i])
-                return false;
-        }
-        
-        return true;
-    }
-    
-    /// Multiply a Vector3 which is assumed to represent position.
-    Vector3 operator * (const Vector3& rhs) const
-    {
-        return Vector3(
-            (m00_ * rhs.x_ + m01_ * rhs.y_ + m02_ * rhs.z_ + m03_),
-            (m10_ * rhs.x_ + m11_ * rhs.y_ + m12_ * rhs.z_ + m13_),
-            (m20_ * rhs.x_ + m21_ * rhs.y_ + m22_ * rhs.z_ + m23_)
-        );
-    }
-    
-    /// Multiply a Vector4.
-    Vector3 operator * (const Vector4& rhs) const
-    {
-        return Vector3(
-            (m00_ * rhs.x_ + m01_ * rhs.y_ + m02_ * rhs.z_ + m03_ * rhs.w_),
-            (m10_ * rhs.x_ + m11_ * rhs.y_ + m12_ * rhs.z_ + m13_ * rhs.w_),
-            (m20_ * rhs.x_ + m21_ * rhs.y_ + m22_ * rhs.z_ + m23_ * rhs.w_)
-        );
-    }
-    
-    /// Add a matrix.
-    Matrix3x4 operator + (const Matrix3x4& rhs) const
-    {
-        return Matrix3x4(
-            m00_ + rhs.m00_,
-            m01_ + rhs.m01_,
-            m02_ + rhs.m02_,
-            m03_ + rhs.m03_,
-            m10_ + rhs.m10_,
-            m11_ + rhs.m11_,
-            m12_ + rhs.m12_,
-            m13_ + rhs.m13_,
-            m20_ + rhs.m20_,
-            m21_ + rhs.m21_,
-            m22_ + rhs.m22_,
-            m23_ + rhs.m23_
-        );
-    }
-    
-    /// Subtract a matrix.
-    Matrix3x4 operator - (const Matrix3x4& rhs) const
-    {
-        return Matrix3x4(
-            m00_ - rhs.m00_,
-            m01_ - rhs.m01_,
-            m02_ - rhs.m02_,
-            m03_ - rhs.m03_,
-            m10_ - rhs.m10_,
-            m11_ - rhs.m11_,
-            m12_ - rhs.m12_,
-            m13_ - rhs.m13_,
-            m20_ - rhs.m20_,
-            m21_ - rhs.m21_,
-            m22_ - rhs.m22_,
-            m23_ - rhs.m23_
-        );
-    }
+    bool operator == (const Matrix3x4& rhs) const;
     
-    /// Multiply with a scalar.
-    Matrix3x4 operator * (float rhs) const
-    {
-        return Matrix3x4(
-            m00_ * rhs,
-            m01_ * rhs,
-            m02_ * rhs,
-            m03_ * rhs,
-            m10_ * rhs,
-            m11_ * rhs,
-            m12_ * rhs,
-            m13_ * rhs,
-            m20_ * rhs,
-            m21_ * rhs,
-            m22_ * rhs,
-            m23_ * rhs
-        );
-    }
+    Vector3 operator * (const Vector3& rhs) const;
+    Vector3 operator * (const Vector4& rhs) const;
     
-    /// Multiply a matrix.
-    Matrix3x4 operator * (const Matrix3x4& rhs) const
-    {
-        return Matrix3x4(
-            m00_ * rhs.m00_ + m01_ * rhs.m10_ + m02_ * rhs.m20_,
-            m00_ * rhs.m01_ + m01_ * rhs.m11_ + m02_ * rhs.m21_,
-            m00_ * rhs.m02_ + m01_ * rhs.m12_ + m02_ * rhs.m22_,
-            m00_ * rhs.m03_ + m01_ * rhs.m13_ + m02_ * rhs.m23_ + m03_,
-            m10_ * rhs.m00_ + m11_ * rhs.m10_ + m12_ * rhs.m20_,
-            m10_ * rhs.m01_ + m11_ * rhs.m11_ + m12_ * rhs.m21_,
-            m10_ * rhs.m02_ + m11_ * rhs.m12_ + m12_ * rhs.m22_,
-            m10_ * rhs.m03_ + m11_ * rhs.m13_ + m12_ * rhs.m23_ + m13_,
-            m20_ * rhs.m00_ + m21_ * rhs.m10_ + m22_ * rhs.m20_,
-            m20_ * rhs.m01_ + m21_ * rhs.m11_ + m22_ * rhs.m21_,
-            m20_ * rhs.m02_ + m21_ * rhs.m12_ + m22_ * rhs.m22_,
-            m20_ * rhs.m03_ + m21_ * rhs.m13_ + m22_ * rhs.m23_ + m23_
-        );
-    }
+    Matrix3x4 operator + (const Matrix3x4& rhs) const;
+    Matrix3x4 operator - (const Matrix3x4& rhs) const;
     
-    /// Multiply a 4x4 matrix.
-    Matrix4 operator * (const Matrix4& rhs) const
-    {
-        return Matrix4(
-            m00_ * rhs.m00_ + m01_ * rhs.m10_ + m02_ * rhs.m20_ + m03_ * rhs.m30_,
-            m00_ * rhs.m01_ + m01_ * rhs.m11_ + m02_ * rhs.m21_ + m03_ * rhs.m31_,
-            m00_ * rhs.m02_ + m01_ * rhs.m12_ + m02_ * rhs.m22_ + m03_ * rhs.m32_,
-            m00_ * rhs.m03_ + m01_ * rhs.m13_ + m02_ * rhs.m23_ + m03_ * rhs.m33_,
-            m10_ * rhs.m00_ + m11_ * rhs.m10_ + m12_ * rhs.m20_ + m13_ * rhs.m30_,
-            m10_ * rhs.m01_ + m11_ * rhs.m11_ + m12_ * rhs.m21_ + m13_ * rhs.m31_,
-            m10_ * rhs.m02_ + m11_ * rhs.m12_ + m12_ * rhs.m22_ + m13_ * rhs.m32_,
-            m10_ * rhs.m03_ + m11_ * rhs.m13_ + m12_ * rhs.m23_ + m13_ * rhs.m33_,
-            m20_ * rhs.m00_ + m21_ * rhs.m10_ + m22_ * rhs.m20_ + m23_ * rhs.m30_,
-            m20_ * rhs.m01_ + m21_ * rhs.m11_ + m22_ * rhs.m21_ + m23_ * rhs.m31_,
-            m20_ * rhs.m02_ + m21_ * rhs.m12_ + m22_ * rhs.m22_ + m23_ * rhs.m32_,
-            m20_ * rhs.m03_ + m21_ * rhs.m13_ + m22_ * rhs.m23_ + m23_ * rhs.m33_,
-            rhs.m30_,
-            rhs.m31_,
-            rhs.m32_,
-            rhs.m33_
-        );
-    }
+    Matrix3x4 operator * (float rhs) const;
+    Matrix3x4 operator * (const Matrix3x4& rhs) const;
+    Matrix4 operator * (const Matrix4& rhs) const;
     
-    /// Set translation elements.
-    void SetTranslation(const Vector3& translation)
-    {
-        m03_ = translation.x_;
-        m13_ = translation.y_;
-        m23_ = translation.z_;
-    }
+    void SetTranslation(const Vector3& translation);
+    void SetRotation(const Matrix3& rotation);
+    void SetScale(const Vector3& scale);
+    void SetScale(float scale);
     
-    /// Set rotation elements from a 3x3 matrix.
-    void SetRotation(const Matrix3& rotation)
-    {
-        m00_ = rotation.m00_;
-        m01_ = rotation.m01_;
-        m02_ = rotation.m02_;
-        m10_ = rotation.m10_;
-        m11_ = rotation.m11_;
-        m12_ = rotation.m12_;
-        m20_ = rotation.m20_;
-        m21_ = rotation.m21_;
-        m22_ = rotation.m22_;
-    }
+    Matrix3 ToMatrix3() const;
+    Matrix3 RotationMatrix() const;
+    Vector3 Translation() const;
+    Quaternion Rotation() const;
+    Vector3 Scale() const;
     
-    /// Set scaling elements.
-    void SetScale(const Vector3& scale)
-    {
-        m00_ = scale.x_;
-        m11_ = scale.y_;
-        m22_ = scale.z_;
-    }
+    bool Equals(const Matrix3x4& rhs) const;
     
-    /// Set uniform scaling elements.
-    void SetScale(float scale)
-    {
-        m00_ = scale;
-        m11_ = scale;
-        m22_ = scale;
-    }
-    
-    /// Return the combined rotation and scaling matrix.
-    Matrix3 ToMatrix3() const
-    {
-        return Matrix3(
-            m00_,
-            m01_,
-            m02_,
-            m10_,
-            m11_,
-            m12_,
-            m20_,
-            m21_,
-            m22_
-        );
-    }
-    
-    /// Return the rotation matrix with scaling removed.
-    Matrix3 RotationMatrix() const
-    {
-        Vector3 invScale(
-            1.0f / sqrtf(m00_ * m00_ + m10_ * m10_ + m20_ * m20_),
-            1.0f / sqrtf(m01_ * m01_ + m11_ * m11_ + m21_ * m21_),
-            1.0f / sqrtf(m02_ * m02_ + m12_ * m12_ + m22_ * m22_)
-        );
-        
-        return ToMatrix3().Scaled(invScale);
-    }
-    
-    /// Return the translation part.
-    Vector3 Translation() const
-    {
-        return Vector3(
-            m03_,
-            m13_,
-            m23_
-        );
-    }
-    
-    /// Return the rotation part.
-    Quaternion Rotation() const { return Quaternion(RotationMatrix()); }
-    
-    /// Return the scaling part.
-    Vector3 Scale() const
-    {
-        return Vector3(
-            sqrtf(m00_ * m00_ + m10_ * m10_ + m20_ * m20_),
-            sqrtf(m01_ * m01_ + m11_ * m11_ + m21_ * m21_),
-            sqrtf(m02_ * m02_ + m12_ * m12_ + m22_ * m22_)
-        );
-    }
-    
-    /// Test for equality with another matrix with epsilon.
-    bool Equals(const Matrix3x4& rhs) const
-    {
-        const float* leftData = Data();
-        const float* rightData = rhs.Data();
-        
-        for (unsigned i = 0; i < 12; ++i)
-        {
-            if (!Urho3D::Equals(leftData[i], rightData[i]))
-                return false;
-        }
-        
-        return true;
-    }
-    
-    /// Return decomposition to translation, rotation and scale.
     void Decompose(Vector3& translation, Quaternion& rotation, Vector3& scale) const;
-    /// Return inverse.
+
     Matrix3x4 Inverse() const;
     
     float m00_ @ m00;
@@ -340,8 +54,6 @@ public:
     float m22_ @ m22;
     float m23_ @ m23;
     
-    /// Zero matrix.
     static const Matrix3x4 ZERO;
-    /// Identity matrix.
     static const Matrix3x4 IDENTITY;
 };

+ 24 - 352
Extras/LuaScript/pkgs/Math/Matrix4.pkg

@@ -1,341 +1,42 @@
 $#include "Matrix4.h"
 
-/// 4x4 matrix for arbitrary linear transforms including projection.
+
 class Matrix4
 {
-public:
-    /// Construct undefined.
-    Matrix4()
-    {
-    }
-    
-    /// Copy-construct from another matrix.
-    Matrix4(const Matrix4& matrix) :
-        m00_(matrix.m00_),
-        m01_(matrix.m01_),
-        m02_(matrix.m02_),
-        m03_(matrix.m03_),
-        m10_(matrix.m10_),
-        m11_(matrix.m11_),
-        m12_(matrix.m12_),
-        m13_(matrix.m13_),
-        m20_(matrix.m20_),
-        m21_(matrix.m21_),
-        m22_(matrix.m22_),
-        m23_(matrix.m23_),
-        m30_(matrix.m30_),
-        m31_(matrix.m31_),
-        m32_(matrix.m32_),
-        m33_(matrix.m33_)
-    {
-    }
-    
-    /// Copy-cnstruct from a 3x3 matrix and set the extra elements to identity.
-    Matrix4(const Matrix3& matrix) :
-        m00_(matrix.m00_),
-        m01_(matrix.m01_),
-        m02_(matrix.m02_),
-        m03_(0.0f),
-        m10_(matrix.m10_),
-        m11_(matrix.m11_),
-        m12_(matrix.m12_),
-        m13_(0.0f),
-        m20_(matrix.m20_),
-        m21_(matrix.m21_),
-        m22_(matrix.m22_),
-        m23_(0.0f),
-        m30_(0.0f),
-        m31_(0.0f),
-        m32_(0.0f),
-        m33_(1.0f)
-    {
-    }
-    
-    // Construct from values.
+    Matrix4();
+    Matrix4(const Matrix4& matrix);
+    Matrix4(const Matrix3& matrix);
     Matrix4(float v00, float v01, float v02, float v03,
             float v10, float v11, float v12, float v13,
             float v20, float v21, float v22, float v23,
-            float v30, float v31, float v32, float v33) :
-        m00_(v00),
-        m01_(v01),
-        m02_(v02),
-        m03_(v03),
-        m10_(v10),
-        m11_(v11),
-        m12_(v12),
-        m13_(v13),
-        m20_(v20),
-        m21_(v21),
-        m22_(v22),
-        m23_(v23),
-        m30_(v30),
-        m31_(v31),
-        m32_(v32),
-        m33_(v33)
-    {
-    }
-    /// Test for equality with another matrix without epsilon.
-    bool operator == (const Matrix4& rhs) const
-    {
-        const float* leftData = Data();
-        const float* rightData = rhs.Data();
-        
-        for (unsigned i = 0; i < 16; ++i)
-        {
-            if (leftData[i] != rightData[i])
-                return false;
-        }
-        
-        return true;
-    }
-    /// Test for equality with another matrix without epsilon.
-    bool operator == (const Matrix4& rhs) const;
-    
-    /// Multiply a Vector3 which is assumed to represent position.
-    Vector3 operator * (const Vector3& rhs) const
-    {
-        float invW = 1.0f / (m30_ * rhs.x_ + m31_ * rhs.y_ + m32_ * rhs.z_ + m33_);
-        
-        return Vector3(
-            (m00_ * rhs.x_ + m01_ * rhs.y_ + m02_ * rhs.z_ + m03_) * invW,
-            (m10_ * rhs.x_ + m11_ * rhs.y_ + m12_ * rhs.z_ + m13_) * invW,
-            (m20_ * rhs.x_ + m21_ * rhs.y_ + m22_ * rhs.z_ + m23_) * invW
-        );
-    }
-    
-    /// Multiply a Vector4.
-    Vector4 operator * (const Vector4& rhs) const
-    {
-        return Vector4(
-            m00_ * rhs.x_ + m01_ * rhs.y_ + m02_ * rhs.z_ + m03_ * rhs.w_,
-            m10_ * rhs.x_ + m11_ * rhs.y_ + m12_ * rhs.z_ + m13_ * rhs.w_,
-            m20_ * rhs.x_ + m21_ * rhs.y_ + m22_ * rhs.z_ + m23_ * rhs.w_,
-            m30_ * rhs.x_ + m31_ * rhs.y_ + m32_ * rhs.z_ + m33_ * rhs.w_
-        );
-    }
-    
-    /// Add a matrix.
-    Matrix4 operator + (const Matrix4& rhs) const
-    {
-        return Matrix4(
-            m00_ + rhs.m00_,
-            m01_ + rhs.m01_,
-            m02_ + rhs.m02_,
-            m03_ + rhs.m03_,
-            m10_ + rhs.m10_,
-            m11_ + rhs.m11_,
-            m12_ + rhs.m12_,
-            m13_ + rhs.m13_,
-            m20_ + rhs.m20_,
-            m21_ + rhs.m21_,
-            m22_ + rhs.m22_,
-            m23_ + rhs.m23_,
-            m30_ + rhs.m30_,
-            m31_ + rhs.m31_,
-            m32_ + rhs.m32_,
-            m33_ + rhs.m33_
-        );
-    }
-    
-    /// Subtract a matrix.
-    Matrix4 operator - (const Matrix4& rhs) const
-    {
-        return Matrix4(
-            m00_ - rhs.m00_,
-            m01_ - rhs.m01_,
-            m02_ - rhs.m02_,
-            m03_ - rhs.m03_,
-            m10_ - rhs.m10_,
-            m11_ - rhs.m11_,
-            m12_ - rhs.m12_,
-            m13_ - rhs.m13_,
-            m20_ - rhs.m20_,
-            m21_ - rhs.m21_,
-            m22_ - rhs.m22_,
-            m23_ - rhs.m23_,
-            m30_ - rhs.m30_,
-            m31_ - rhs.m31_,
-            m32_ - rhs.m32_,
-            m33_ - rhs.m33_
-        );
-    }
-    
-    /// Multiply with a scalar.
-    Matrix4 operator * (float rhs) const
-    {
-        return Matrix4(
-            m00_ * rhs,
-            m01_ * rhs,
-            m02_ * rhs,
-            m03_ * rhs,
-            m10_ * rhs,
-            m11_ * rhs,
-            m12_ * rhs,
-            m13_ * rhs,
-            m20_ * rhs,
-            m21_ * rhs,
-            m22_ * rhs,
-            m23_ * rhs,
-            m30_ * rhs,
-            m31_ * rhs,
-            m32_ * rhs,
-            m33_ * rhs
-        );
-    }
+            float v30, float v31, float v32, float v33);
     
-    /// Multiply a matrix.
-    Matrix4 operator * (const Matrix4& rhs) const
-    {
-        return Matrix4(
-            m00_ * rhs.m00_ + m01_ * rhs.m10_ + m02_ * rhs.m20_ + m03_ * rhs.m30_,
-            m00_ * rhs.m01_ + m01_ * rhs.m11_ + m02_ * rhs.m21_ + m03_ * rhs.m31_,
-            m00_ * rhs.m02_ + m01_ * rhs.m12_ + m02_ * rhs.m22_ + m03_ * rhs.m32_,
-            m00_ * rhs.m03_ + m01_ * rhs.m13_ + m02_ * rhs.m23_ + m03_ * rhs.m33_,
-            m10_ * rhs.m00_ + m11_ * rhs.m10_ + m12_ * rhs.m20_ + m13_ * rhs.m30_,
-            m10_ * rhs.m01_ + m11_ * rhs.m11_ + m12_ * rhs.m21_ + m13_ * rhs.m31_,
-            m10_ * rhs.m02_ + m11_ * rhs.m12_ + m12_ * rhs.m22_ + m13_ * rhs.m32_,
-            m10_ * rhs.m03_ + m11_ * rhs.m13_ + m12_ * rhs.m23_ + m13_ * rhs.m33_,
-            m20_ * rhs.m00_ + m21_ * rhs.m10_ + m22_ * rhs.m20_ + m23_ * rhs.m30_,
-            m20_ * rhs.m01_ + m21_ * rhs.m11_ + m22_ * rhs.m21_ + m23_ * rhs.m31_,
-            m20_ * rhs.m02_ + m21_ * rhs.m12_ + m22_ * rhs.m22_ + m23_ * rhs.m32_,
-            m20_ * rhs.m03_ + m21_ * rhs.m13_ + m22_ * rhs.m23_ + m23_ * rhs.m33_,
-            m30_ * rhs.m00_ + m31_ * rhs.m10_ + m32_ * rhs.m20_ + m33_ * rhs.m30_,
-            m30_ * rhs.m01_ + m31_ * rhs.m11_ + m32_ * rhs.m21_ + m33_ * rhs.m31_,
-            m30_ * rhs.m02_ + m31_ * rhs.m12_ + m32_ * rhs.m22_ + m33_ * rhs.m32_,
-            m30_ * rhs.m03_ + m31_ * rhs.m13_ + m32_ * rhs.m23_ + m33_ * rhs.m33_
-        );
-    }
-    
-    /// Set translation elements.
-    void SetTranslation(const Vector3& translation)
-    {
-        m03_ = translation.x_;
-        m13_ = translation.y_;
-        m23_ = translation.z_;
-    }
-    
-    /// Set rotation elements from a 3x3 matrix.
-    void SetRotation(const Matrix3& rotation)
-    {
-        m00_ = rotation.m00_;
-        m01_ = rotation.m01_;
-        m02_ = rotation.m02_;
-        m10_ = rotation.m10_;
-        m11_ = rotation.m11_;
-        m12_ = rotation.m12_;
-        m20_ = rotation.m20_;
-        m21_ = rotation.m21_;
-        m22_ = rotation.m22_;
-    }
-    
-    // Set scaling elements.
-    void SetScale(const Vector3& scale)
-    {
-        m00_ = scale.x_;
-        m11_ = scale.y_;
-        m22_ = scale.z_;
-    }
-    
-    // Set uniform scaling elements.
-    void SetScale(float scale)
-    {
-        m00_ = scale;
-        m11_ = scale;
-        m22_ = scale;
-    }
-    
-    /// Return the combined rotation and scaling matrix.
-    Matrix3 ToMatrix3() const
-    {
-        return Matrix3(
-            m00_,
-            m01_,
-            m02_,
-            m10_,
-            m11_,
-            m12_,
-            m20_,
-            m21_,
-            m22_
-        );
-    }
-    
-    /// Return the rotation matrix with scaling removed.
-    Matrix3 RotationMatrix() const
-    {
-        Vector3 invScale(
-            1.0f / sqrtf(m00_ * m00_ + m10_ * m10_ + m20_ * m20_),
-            1.0f / sqrtf(m01_ * m01_ + m11_ * m11_ + m21_ * m21_),
-            1.0f / sqrtf(m02_ * m02_ + m12_ * m12_ + m22_ * m22_)
-        );
-        
-        return ToMatrix3().Scaled(invScale);
-    }
+    bool operator == (const Matrix4& rhs) const;
     
-    /// Return the translation part.
-    Vector3 Translation() const
-    {
-        return Vector3(
-            m03_,
-            m13_,
-            m23_
-        );
-    }
+    Vector3 operator * (const Vector3& rhs) const;
+    Vector4 operator * (const Vector4& rhs) const;
     
-    /// Return the rotation part.
-    Quaternion Rotation() const { return Quaternion(RotationMatrix()); }
+    Matrix4 operator + (const Matrix4& rhs) const;
+    Matrix4 operator - (const Matrix4& rhs) const;
     
-    /// Return the scaling part
-    Vector3 Scale() const
-    {
-        return Vector3(
-            sqrtf(m00_ * m00_ + m10_ * m10_ + m20_ * m20_),
-            sqrtf(m01_ * m01_ + m11_ * m11_ + m21_ * m21_),
-            sqrtf(m02_ * m02_ + m12_ * m12_ + m22_ * m22_)
-        );
-    }
+    Matrix4 operator * (float rhs) const;
+    Matrix4 operator * (const Matrix4& rhs) const;
     
-    /// Return transpose
-    Matrix4 Transpose() const
-    {
-        return Matrix4(
-            m00_,
-            m10_,
-            m20_,
-            m30_,
-            m01_,
-            m11_,
-            m21_,
-            m31_,
-            m02_,
-            m12_,
-            m22_,
-            m32_,
-            m03_,
-            m13_,
-            m23_,
-            m33_
-        );
-    }
+    void SetTranslation(const Vector3& translation);
+    void SetRotation(const Matrix3& rotation);
+    void SetScale(const Vector3& scale);
+    void SetScale(float scale);
     
-    /// Test for equality with another matrix with epsilon.
-    bool Equals(const Matrix4& rhs) const
-    {
-        const float* leftData = Data();
-        const float* rightData = rhs.Data();
-        
-        for (unsigned i = 0; i < 16; ++i)
-        {
-            if (!Urho3D::Equals(leftData[i], rightData[i]))
-                return false;
-        }
-        
-        return true;
-    }
+    Matrix3 ToMatrix3() const;
+    Matrix3 RotationMatrix() const;
+    Vector3 Translation() const;
+    Quaternion Rotation() const;
+    Vector3 Scale() const;
+    Matrix4 Transpose() const;
     
-    /// Return decomposition to translation, rotation and scale
+    bool Equals(const Matrix4& rhs) const;
     void Decompose(Vector3& translation, Quaternion& rotation, Vector3& scale) const;
-    /// Return inverse
+    
     Matrix4 Inverse() const;
     
     float m00_ @ m00;
@@ -355,35 +56,6 @@ public:
     float m32_ @ m32;
     float m33_ @ m33;
     
-    /// Bulk transpose matrices.
-    static void BulkTranspose(float* dest, const float* src, unsigned count)
-    {
-        for (unsigned i = 0; i < count; ++i)
-        {
-            dest[0] = src[0];
-            dest[1] = src[4];
-            dest[2] = src[8];
-            dest[3] = src[12];
-            dest[4] = src[1];
-            dest[5] = src[5];
-            dest[6] = src[9];
-            dest[7] = src[13];
-            dest[8] = src[2];
-            dest[9] = src[6];
-            dest[10] = src[10];
-            dest[11] = src[14];
-            dest[12] = src[3];
-            dest[13] = src[7];
-            dest[14] = src[11];
-            dest[15] = src[15];
-            
-            dest += 16;
-            src += 16;
-        }
-    }
-    
-    /// Zero matrix.
     static const Matrix4 ZERO;
-    /// Identity matrix.
     static const Matrix4 IDENTITY;
 };

+ 8 - 42
Extras/LuaScript/pkgs/Math/Polyhedron.pkg

@@ -1,60 +1,26 @@
 $#include "Polyhedron.h"
 
-/// A convex volume built from polygon faces.
 class Polyhedron
 {
-public:
-    /// Construct empty.
-    Polyhedron()
-    {
-    }
-    
-    /// Copy-construct from another polyhedron.
-    Polyhedron(const Polyhedron& polyhedron) :
-        faces_(polyhedron.faces_)
-    {
-    }
-    
-    /// Construct from a bounding box.
-    Polyhedron(const BoundingBox& box)
-    {
-        Define(box);
-    }
-    
-    /// Construct from a frustum.
-    Polyhedron(const Frustum& frustum)
-    {
-        Define(frustum);
-    }
-    
-    /// Destruct.
+    Polyhedron();
+    Polyhedron(const Polyhedron& polyhedron);
+    Polyhedron(const BoundingBox& box);
+    Polyhedron(const Frustum& frustum);
     ~Polyhedron();
-    
-    /// Define from a bounding box.
+
     void Define(const BoundingBox& box);
-    /// Define from a frustum.
     void Define(const Frustum& frustum);
-    /// Add a triangle face.
     void AddFace(const Vector3& v0, const Vector3& v1, const Vector3& v2);
-    /// Add a quadrilateral face.
     void AddFace(const Vector3& v0, const Vector3& v1, const Vector3& v2, const Vector3& v3);
-    /// Clip with a plane.
     void Clip(const Plane& plane);
-    /// Clip with a bounding box.
     void Clip(const BoundingBox& box);
-    /// Clip with a frustum.
     void Clip(const Frustum& box);
-    /// Clear all faces.
     void Clear();
-    /// Transform with a 3x3 matrix.
     void Transform(const Matrix3& transform);
-    /// Transform with a 3x4 matrix.
     void Transform(const Matrix3x4& transform);
-    
-    /// Return transformed with a 3x3 matrix.
     Polyhedron Transformed(const Matrix3& transform) const;
-    /// Return transformed with a 3x4 matrix.
     Polyhedron Transformed(const Matrix3x4& transform) const;
-    /// Return whether is empty.
-    bool Empty() const { return faces_.Empty(); }
+    bool Empty() const;
+    
+    tolua_readonly tolua_property__no_prefix bool empty;
 };

+ 24 - 151
Extras/LuaScript/pkgs/Math/Quaternion.pkg

@@ -1,183 +1,56 @@
 $#include "Quaternion.h"
 
-/// Rotation represented as a four-dimensional normalized vector.
 class Quaternion
 {
-public:
-    /// Construct identity quaternion.
-    Quaternion() :
-        w_(1.0f),
-        x_(0.0f),
-        y_(0.0f),
-        z_(0.0f)
-    {
-    }
-    
-    /// Copy-construct from another quaternion.
-    Quaternion(const Quaternion& quat) :
-        w_(quat.w_),
-        x_(quat.x_),
-        y_(quat.y_),
-        z_(quat.z_)
-    {
-    }
-    
-    /// Construct from values.
-    Quaternion(float w, float x, float y, float z) :
-        w_(w),
-        x_(x),
-        y_(y),
-        z_(z)
-    {
-    }
-    
-    /// Construct from an angle (in degrees) and axis.
-    Quaternion(float angle, const Vector3& axis)
-    {
-        FromAngleAxis(angle, axis);
-    }
-    
-    /// Construct from Euler angles (in degrees.)
-    Quaternion(float x, float y, float z)
-    {
-        FromEulerAngles(x, y, z);
-    }
-    
-    /// Construct from the rotation difference between two vectors.
-    Quaternion(const Vector3& start, const Vector3& end)
-    {
-        FromRotationTo(start, end);
-    }
-    
-    /// Construct from orthonormal axes.
-    Quaternion(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis)
-    {
-        FromAxes(xAxis, yAxis, zAxis);
-    }
+    Quaternion();
+    Quaternion(const Quaternion& quat);
+    Quaternion(float w, float x, float y, float z);
+    Quaternion(float angle, const Vector3& axis);
+    Quaternion(float x, float y, float z);
+    Quaternion(const Vector3& start, const Vector3& end);
+    Quaternion(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis);
+    Quaternion(const Matrix3& matrix);
 
-    /// Construct from a rotation matrix.
-    Quaternion(const Matrix3& matrix)
-    {
-        FromRotationMatrix(matrix);
-    }
-    
-    /// Test for equality with another quaternion without epsilon.
     bool operator == (const Quaternion& rhs) const;
-	
-	/// Multiply with a scalar.
-    Quaternion operator * (float rhs) const;
     
-	/// Return negation.
+    Quaternion operator * (float rhs) const;
     Quaternion operator - () const;
+    bool operator == (const Quaternion& rhs) const;
     
-    /// Test for equality with another quaternion without epsilon.
-    bool operator == (const Quaternion& rhs) const { return w_ == rhs.w_ && x_ == rhs.x_ && y_ == rhs.y_ && z_ == rhs.z_; }
-    /// Multiply with a scalar.
-    Quaternion operator * (float rhs) const { return Quaternion(w_ * rhs, x_ * rhs, y_ * rhs, z_ * rhs); }
-    /// Return negation.
-    Quaternion operator - () const { return Quaternion(-w_, -x_, -y_, -z_); }
-    /// Add a quaternion.
-    Quaternion operator + (const Quaternion& rhs) const { return Quaternion(w_ + rhs.w_, x_ + rhs.x_, y_ + rhs.y_, z_ + rhs.z_); }
-    /// Subtract a quaternion.
-    Quaternion operator - (const Quaternion& rhs) const { return Quaternion(w_ - rhs.w_, x_ - rhs.x_, y_ - rhs.y_, z_ - rhs.z_); }
-    
-    /// Multiply a quaternion.
-    Quaternion operator * (const Quaternion& rhs) const
-    {
-        return Quaternion(
-            w_ * rhs.w_ - x_ * rhs.x_ - y_ * rhs.y_ - z_ * rhs.z_,
-            w_ * rhs.x_ + x_ * rhs.w_ + y_ * rhs.z_ - z_ * rhs.y_,
-            w_ * rhs.y_ + y_ * rhs.w_ + z_ * rhs.x_ - x_ * rhs.z_,
-            w_ * rhs.z_ + z_ * rhs.w_ + x_ * rhs.y_ - y_ * rhs.x_
-        );
-    }
-    
-    /// Multiply a Vector3.
-    Vector3 operator * (const Vector3& rhs) const
-    {
-        Vector3 qVec(x_,y_,z_);
-        Vector3 cross1(qVec.CrossProduct(rhs));
-        Vector3 cross2(qVec.CrossProduct(cross1));
-        
-        return rhs + 2.0f * (cross1 * w_ + cross2);
-    }
+    Quaternion operator * (float rhs) const;
+    Quaternion operator - () const;
+    Quaternion operator + (const Quaternion& rhs) const;
+    Quaternion operator - (const Quaternion& rhs) const;
+    Quaternion operator * (const Quaternion& rhs) const;
+    Vector3 operator * (const Vector3& rhs) const;
     
-    /// Define from an angle (in degrees) and axis.
     void FromAngleAxis(float angle, const Vector3& axis);
-    /// Define from Euler angles (in degrees.)
     void FromEulerAngles(float x, float y, float z);
-    /// Define from the rotation difference between two vectors.
     void FromRotationTo(const Vector3& start, const Vector3& end);
-    /// Define from orthonormal axes.
     void FromAxes(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis);
-    /// Define from a rotation matrix.
     void FromRotationMatrix(const Matrix3& matrix);
     
-    /// Normalize to unit length and return the previous length.
-    float Normalize()
-    {
-        float len = sqrtf(LengthSquared());
-        if (len >= M_EPSILON)
-            *this *= (1.0f / len);
-
-        return len;
-    }
+    float Normalize();
     
-    /// Return normalized to unit length.
-    Quaternion Normalized() const
-    {
-        float lenSquared = LengthSquared();
-        if (lenSquared >= M_EPSILON * M_EPSILON)
-            return *this * (1.0f / sqrtf(lenSquared));
-        else
-            return IDENTITY;
-    }
+    Quaternion Normalized() const;
+    Quaternion Inverse() const;
+    float LengthSquared() const;
+    float DotProduct(const Quaternion& rhs) const;
+    bool Equals(const Quaternion& rhs) const;
     
-    /// Return inverse.
-    Quaternion Inverse() const
-    {
-        float lenSquared = LengthSquared();
-        if (lenSquared == 1.0f)
-            return Conjugate();
-        else if (lenSquared >= M_EPSILON)
-            return Conjugate() * (1.0f / lenSquared);
-        else
-            return IDENTITY;
-    }
-    
-    /// Return squared length.
-    float LengthSquared() const { return w_ * w_ + x_ * x_ + y_ * y_ + z_ * z_; }
-    /// Calculate dot product.
-    float DotProduct(const Quaternion& rhs) const { return w_ * rhs.w_ + x_ * rhs.x_ + y_ * rhs.y_ + z_ * rhs.z_; }
-    /// Test for equality with another quaternion with epsilon.
-    bool Equals(const Quaternion& rhs) const { return Urho3D::Equals(w_, rhs.w_) && Urho3D::Equals(x_, rhs.x_) && Urho3D::Equals(y_, rhs.y_) && Urho3D::Equals(z_, rhs.z_); }
-    /// Return conjugate.
-    Quaternion Conjugate() const { return Quaternion(w_, -x_, -y_, -z_); }
-    
-    /// Return Euler angles in degrees.
+    Quaternion Conjugate() const;
     Vector3 EulerAngles() const;
-    /// Return yaw angle in degrees.
     float YawAngle() const;
-    /// Return pitch angle in degrees.
     float PitchAngle() const;
-    /// Return roll angle in degrees.
     float RollAngle() const;
-    /// Return the rotation matrix that corresponds to this quaternion.
     Matrix3 RotationMatrix() const;
-    /// Spherical interpolation with another quaternion.
     Quaternion Slerp(Quaternion rhs, float t) const;
-    /// Return as string.
     String ToString() const;
-    
-    /// W coordinate.
+
     float w_ @ w;
-    /// X coordinate.
     float x_ @ x;
-    /// Y coordinate.
     float y_ @ y;
-    /// Z coordinate.
     float z_ @ z;
     
-    /// Identity quaternion.
     static const Quaternion IDENTITY;
 };

+ 0 - 5
Extras/LuaScript/pkgs/Math/Random.pkg

@@ -1,10 +1,5 @@
 $#include "Random.h"
 
-/// Set the random seed. The default seed is 1.
 void SetRandomSeed(unsigned seed);
-
-/// Return the current random seed.
 unsigned GetRandomSeed();
-
-/// Return a random number between 0-32767. Should operate similarly to MSVC rand().
 int Rand();

+ 0 - 1
Extras/LuaScript/pkgs/Math/Ray.pkg

@@ -18,7 +18,6 @@ public:
     float HitDistance(const Plane& plane) const;
     float HitDistance(const BoundingBox& box) const;
     
-    float HitDistance(const Frustum& frustum) const;
     float HitDistance(const Frustum& frustum, bool solidInside = true) const;
     
     float HitDistance(const Sphere& sphere) const;

+ 28 - 155
Extras/LuaScript/pkgs/Math/Rect.pkg

@@ -1,187 +1,60 @@
 $#include "Rect.h"
 
-/// Two-dimensional bounding rectangle.
 class Rect
 {
-public:
-    /// Construct an undefined rect.
-    Rect() :
-        min_(Vector2::ZERO),
-        max_(Vector2::ZERO),
-        defined_(false)
-    {
-    }
-    
-    /// Copy-construct from another rect.
-    Rect(const Rect& rect) :
-        min_(rect.min_),
-        max_(rect.max_),
-        defined_(rect.defined_)
-    {
-    }
-    
-    /// Construct from minimum and maximum vectors.
-    Rect(const Vector2& min, const Vector2& max) :
-        min_(min),
-        max_(max),
-        defined_(true)
-    {
-    }
-    
-    /// Construct from coordinates.
-    Rect(float left, float top, float right, float bottom) :
-        min_(left, top),
-        max_(right, bottom),
-        defined_(true)
-    {
-    }
-    
-    /// Construct from a Vector4.
-    Rect(const Vector4& vector) :
-        min_(vector.x_, vector.y_),
-        max_(vector.z_, vector.w_),
-        defined_(true)
-    {
-    }
+    Rect();
+    Rect(const Rect& rect);
+    Rect(const Vector2& min, const Vector2& max);
+    Rect(float left, float top, float right, float bottom);
+    Rect(const Vector4& vector);
 
-    /// Test for equality with another rect.
-    bool operator == (const Rect& rhs) const { return min_ == rhs.min_ && max_ == rhs.max_; }
-
-    /// Define from another rect.
-    void Define(const Rect& rect)
-    {
-        min_ = rect.min_;
-        max_ = rect.max_;
-        defined_ = true;
-    }
-    
-    /// Define from minimum and maximum vectors.
-    void Define(const Vector2& min, const Vector2& max)
-    {
-        min_ = min;
-        max_ = max;
-        defined_ = true;
-    }
-    
-    /// Define from a point.
-    void Define(const Vector2& point)
-    {
-        min_ = max_ = point;
-        defined_ = true;
-    }
-    
-    /// Merge a point.
-    void Merge(const Vector2& point)
-    {
-        if (!defined_)
-        {
-            min_ = max_ = point;
-            defined_ = true;
-        }
-        
-        if (point.x_ < min_.x_)
-            min_.x_ = point.x_;
-        if (point.x_ > max_.x_)
-            max_.x_ = point.x_;
-        if (point.y_ < min_.y_)
-            min_.y_ = point.y_;
-        if (point.y_ > max_.y_)
-            max_.y_ = point.y_;
-    }
-    
-    /// Merge a rect.
-    void Merge(const Rect& rect)
-    {
-        if (!defined_)
-        {
-            min_ = rect.min_;
-            max_ = rect.max_;
-            defined_ = true;
-        }
-        
-        if (rect.min_.x_ < min_.x_)
-            min_.x_ = rect.min_.x_;
-        if (rect.min_.y_ < min_.y_)
-            min_.y_ = rect.min_.y_;
-        if (rect.max_.x_ > max_.x_)
-            max_.x_ = rect.max_.x_;
-        if (rect.max_.y_ > max_.y_)
-            max_.y_ = rect.max_.y_;
-    }
-    
-    /// Clear to undefined state.
-    void Clear()
-    {
-        min_ = Vector2::ZERO;
-        max_ = Vector2::ZERO;
-        defined_ = false;
-    }
-    
-    /// Clip with another rect.
+    bool operator == (const Rect& rhs) const;
+    
+    void Define(const Rect& rect);
+    void Define(const Vector2& min, const Vector2& max);
+    void Define(const Vector2& point);
+    void Merge(const Vector2& point);
+    void Merge(const Rect& rect);
+    void Clear();
     void Clip(const Rect& rect);
+    Vector2 Center() const;
+    Vector2 Size() const;
+    Vector2 HalfSize() const;
+    bool Equals(const Rect& rhs) const;
+    Vector4 ToVector4() const;
     
-    /// Return center.
-    Vector2 Center() const { return (max_ + min_) * 0.5f; }
-    /// Return size.
-    Vector2 Size() const { return max_ - min_; }
-    /// Return half-size.
-    Vector2 HalfSize() const { return (max_ - min_) * 0.5f; }
-    /// Test for equality with another rect with epsilon.
-    bool Equals(const Rect& rhs) const { return min_.Equals(rhs.min_) && max_.Equals(rhs.max_); }
-    
-    /// Return as a vector.
-    Vector4 ToVector4() const { return Vector4(min_.x_, min_.y_, max_.x_, max_.y_); }
-    /// Return as string.
     String ToString() const;
-
-    /// Minimum vector.
-    Vector2 min_ @ min;
     
-    /// Maximum vector.
+    Vector2 min_ @ min;
     Vector2 max_ @ max;
-    
-    /// Rect in the range (-1, -1) - (1, 1)
     static const Rect FULL;
-    /// Rect in the range (0, 0) - (1, 1)
     static const Rect POSITIVE;
-    /// Zero-sized rect.
     static const Rect ZERO;
+    
+    tolua_readonly tolua_property__no_prefix Vector2 center;
+    tolua_readonly tolua_property__no_prefix Vector2 size;
+    tolua_readonly tolua_property__no_prefix Vector2 halfSize;
 };
 
-/// Two-dimensional bounding rectangle with integer values.
 class IntRect
 {
-public:
-    /// Construct an undefined rect.
     IntRect();
-    
-    /// Construct from coordinates.
     IntRect(int left, int top, int right, int bottom);
-    
-    /// Test for equality with another rect.
+
     bool operator == (const IntRect& rhs) const;
     
-    /// Return size.
     IntVector2 Size() const;
-    
-    /// Return width.
     int Width() const;
-    
-    /// Return height.
     int Height() const;
     
-    /// Left coordinate.
     int left_ @ left;
-    
-    /// Top coordinate.
     int top_ @ top;
-    
-    /// Right coordinate.
     int right_ @ right;
-    
-    /// Bottom coordinate.
     int bottom_ @ bottom;
     
-    /// Zero-sized rect.
     static const IntRect ZERO;
+    
+    tolua_readonly tolua_property__no_prefix IntVector2 size;
+    tolua_readonly tolua_property__no_prefix int width;
+    tolua_readonly tolua_property__no_prefix int height;
 };

+ 18 - 70
Extras/LuaScript/pkgs/Math/StringHash.pkg

@@ -1,97 +1,45 @@
 $#include "StringHash.h"
 
-/// 32-bit hash value for a string.
 class StringHash
 {
-public:
-    /// Construct with zero value.
-    StringHash() :
-        value_(0)
-    {
-    }
-    
-    /// Copy-construct from another hash.
-    StringHash(const StringHash& rhs) :
-        value_(rhs.value_)
-    {
-    }
-    
-    /// Construct with an initial value.
-    explicit StringHash(unsigned value) :
-        value_(value)
-    {
-    }
-    
-    /// Construct from a C string case-insensitively.
+    StringHash();
+    StringHash(const StringHash& rhs);
+    explicit StringHash(unsigned value);
     StringHash(const char* str);
-    /// Construct from a string case-insensitively.
     StringHash(const String& str);
-    
-    /// Add a hash.
-    StringHash operator + (const StringHash& rhs) const
-    {
-        StringHash ret;
-        ret.value_ = value_ + rhs.value_;
-        return ret;
-    }
-    
-    // Test for equality with another hash.
-    bool operator == (const StringHash& rhs) const { return value_ == rhs.value_; }
-    /// Test if less than another hash.
-    bool operator < (const StringHash& rhs) const { return value_ < rhs.value_; }
-    /// Return true if nonzero hash value.
-    operator bool () const { return value_ != 0; }
-    /// Return hash value.
-    unsigned Value() const { return value_; }
-    /// Return as string.
+
+    StringHash operator + (const StringHash& rhs) const;
+    bool operator == (const StringHash& rhs) const;
+    bool operator < (const StringHash& rhs) const;
+    operator bool () const;
+    unsigned Value() const;
     String ToString() const;
-    /// Return hash value for HashSet & HashMap.
-    unsigned ToHash() const { return value_; }
+    unsigned ToHash() const;
     
-    /// Calculate hash value case-insensitively from a C string.
     static unsigned Calculate(const char* str);
-    
-    /// Zero hash.
     static const StringHash ZERO;
+    
+    tolua_readonly tolua_property__no_prefix unsigned value;
 };
 
-/// 16-bit hash value for a string.
+
 class ShortStringHash
 {
 public:
-    /// Construct with zero hash value.
     ShortStringHash();
-    
-    /// Copy-construct from another hash value.
     ShortStringHash(const ShortStringHash& rhs);
-    
-    /// Copy-construct from another 32-bit hash value (ignore the high bits.)
     explicit ShortStringHash(const StringHash& rhs);
-    
-    /// Construct with an initial value.
     explicit ShortStringHash(unsigned short value);
-
-    /// Construct from a C string case-insensitively.
     ShortStringHash(const char* str);
-    
-    /// Construct from a string case-insensitively.
     ShortStringHash(const String& str);
-    
-    /// Add a hash.
+
     ShortStringHash operator + (const ShortStringHash& rhs) const;
-    
-    /// Test for equality with another hash.
     bool operator == (const ShortStringHash& rhs) const;
-    
-    /// Test if less than another hash.
     bool operator < (const ShortStringHash& rhs) const;
-    
-    /// Return hash value.
-    unsigned short Value() const { return value_; }
-    
-    /// Calculate hash value case-insensitively from a C string.
+    unsigned short Value() const;
+
     static unsigned short Calculate(const char* str);
-    
-    /// Zero hash.
     static const ShortStringHash ZERO;
+    
+    tolua_readonly tolua_property__no_prefix unsigned short value;
 };

+ 35 - 135
Extras/LuaScript/pkgs/Math/Vector2.pkg

@@ -1,165 +1,65 @@
 $#include "Vector2.h"
 
-/// Two-dimensional vector.
 class Vector2
 {
-public:
-    /// Construct undefined.
-    Vector2()
-    {
-    }
-    
-    /// Copy-construct from another vector.
-    Vector2(const Vector2& vector) :
-        x_(vector.x_),
-        y_(vector.y_)
-    {
-    }
-    
-    /// Construct from coordinates.
-    Vector2(float x, float y) :
-        x_(x),
-        y_(y)
-    {
-    }
-    
-    /// Construct from a float array.
-    Vector2(const float* data) :
-        x_(data[0]),
-        y_(data[1])
-    {
-    }
-    
-    /// Test for equality with another vector without epsilon.
-    bool operator == (const Vector2& rhs) const { return x_ == rhs.x_ && y_ == rhs.y_; }
-    /// Add a vector.
-    Vector2 operator + (const Vector2& rhs) const { return Vector2(x_ + rhs.x_, y_ + rhs.y_); }
-    /// Return negation.
-    Vector2 operator - () const { return Vector2(-x_, -y_); }
-    /// Subtract a vector.
-    Vector2 operator - (const Vector2& rhs) const { return Vector2(x_ - rhs.x_, y_ - rhs.y_); }
-    /// Multiply with a scalar.
-    Vector2 operator * (float rhs) const { return Vector2(x_ * rhs, y_ * rhs); }
-    /// Multiply with a vector.
-    Vector2 operator * (const Vector2& rhs) const { return Vector2(x_ * rhs.x_, y_ * rhs.y_); }
-    /// Divide by a scalar.
-    Vector2 operator / (float rhs) const { return Vector2(x_ / rhs, y_ / rhs); }
-    /// Divide by a vector.
-    Vector2 operator / (const Vector2& rhs) const { return Vector2(x_ / rhs.x_, y_ / rhs.y_); }
+    Vector2();
+    Vector2(const Vector2& vector);
+    Vector2(float x, float y);
+    Vector2(const float* data);
+    
+    bool operator == (const Vector2& rhs) const;
+    Vector2 operator + (const Vector2& rhs) const;
+    Vector2 operator - () const;
+    Vector2 operator - (const Vector2& rhs) const;
+    Vector2 operator * (float rhs) const;
+    Vector2 operator * (const Vector2& rhs) const;
+    Vector2 operator / (float rhs) const;
     Vector2 operator / (const Vector2& rhs) const;
+    Vector2 operator / (const Vector2& rhs) const;
+
+    float Normalize();
+    float Length() const;
+    float LengthSquared() const;
+    float DotProduct(const Vector2& rhs) const;
+    float AbsDotProduct(const Vector2& rhs) const;
+    Vector2 Abs() const;
+    Vector2 Lerp(const Vector2& rhs, float t) const;
+    bool Equals(const Vector2& rhs) const;
     
-    /// Normalize to unit length and return the previous length.
-    float Normalize()
-    {
-        float len = Length();
-        if (len >= M_EPSILON)
-        {
-            float invLen = 1.0f / len;
-            x_ *= invLen;
-            y_ *= invLen;
-        }
-        
-        return len;
-    }
-    
-    /// Return length.
-    float Length() const { return sqrtf(x_ * x_ + y_ * y_); }
-    /// Return squared length.
-    float LengthSquared() const { return x_ * x_ + y_ * y_; }
-    /// Calculate dot product.
-    float DotProduct(const Vector2& rhs) const { return x_ * rhs.x_ + y_ * rhs.y_; }
-    /// Calculate absolute dot product.
-    float AbsDotProduct(const Vector2& rhs) const { return Urho3D::Abs(x_ * rhs.x_) + Urho3D::Abs(y_ * rhs.y_); }
-    /// Return absolute vector.
-    Vector2 Abs() const { return Vector2(Urho3D::Abs(x_), Urho3D::Abs(y_)); }
-    /// Linear interpolation with another vector.
-    Vector2 Lerp(const Vector2& rhs, float t) const { return *this * (1.0f - t) + rhs * t; }
-    /// Test for equality with another vector with epsilon.
-    bool Equals(const Vector2& rhs) const { return Urho3D::Equals(x_, rhs.x_) && Urho3D::Equals(y_, rhs.y_); }
-    
-    /// Return normalized to unit length.
-    Vector2 Normalized() const
-    {
-        float len = Length();
-        if (len >= M_EPSILON)
-            return *this * (1.0f / len);
-        else
-            return *this;
-    }
+    Vector2 Normalized() const;
     
-    /// Return as string.
     String ToString() const;
-    /// X coordinate.
+    
     float x_ @ x;
-    /// Y coordinate.
     float y_ @ y;
     
-    /// Zero vector.
     static const Vector2 ZERO;
-    /// (-1,0) vector.
     static const Vector2 LEFT;
-    /// (1,0) vector.
     static const Vector2 RIGHT;
-    /// (0,1) vector.
     static const Vector2 UP;
-    /// (0,-1) vector.
     static const Vector2 DOWN;
-    /// (1,1) vector.
     static const Vector2 ONE;
 };
 
-/// Two-dimensional vector with integer values.
 class IntVector2
 {
-public:
-    /// Construct undefined.
-    IntVector2()
-    {
-    }
-    
-    /// Construct from coordinates.
-    IntVector2(int x, int y) :
-        x_(x),
-        y_(y)
-    {
-    }
-    
-    /// Construct from an int array.
-    IntVector2(const int* data) :
-        x_(data[0]),
-        y_(data[1])
-    {
-    }
-    
-    /// Copy-construct from another vector.
-    IntVector2(const IntVector2& rhs) :
-        x_(rhs.x_),
-        y_(rhs.y_)
-    {
-    }
-    
-    /// Test for equality with another vector.
-    bool operator == (const IntVector2& rhs) const { return x_ == rhs.x_ && y_ == rhs.y_; }
-    /// Add a vector.
-    IntVector2 operator + (const IntVector2& rhs) const { return IntVector2(x_ + rhs.x_, y_ + rhs.y_); }
-    /// Return negation.
-    IntVector2 operator - () const { return IntVector2(-x_, -y_); }
-    /// Subtract a vector.
-    IntVector2 operator - (const IntVector2& rhs) const { return IntVector2(x_ - rhs.x_, y_ - rhs.y_); }
-    /// Multiply with a scalar.
-    IntVector2 operator * (int rhs) const { return IntVector2(x_ * rhs, y_ * rhs); }
-    /// Divide by a scalar.
-    IntVector2 operator / (int rhs) const { return IntVector2(x_ / rhs, y_ / rhs); }
+    IntVector2();
+    IntVector2(int x, int y);
+    IntVector2(const int* data);
+    IntVector2(const IntVector2& rhs);
+
+    bool operator == (const IntVector2& rhs) const;
+    IntVector2 operator + (const IntVector2& rhs) const;
+    IntVector2 operator - () const;
+    IntVector2 operator - (const IntVector2& rhs) const;
+    IntVector2 operator * (int rhs) const;
+    IntVector2 operator / (int rhs) const;
     IntVector2 operator / (int rhs) const;
     
-    /// Return as string.
     String ToString() const;
     
-    /// X coordinate.
     int x_ @ x;
-    /// Y coordinate.
     int y_ @ y;
     
-    /// Zero vector.
     static const IntVector2 ZERO;
 };

+ 24 - 110
Extras/LuaScript/pkgs/Math/Vector3.pkg

@@ -1,131 +1,45 @@
 $#include "Vector3.h"
 
-/// Three-dimensional vector.
+
 class Vector3
 {
-public:
-    /// Construct undefined.
-    Vector3()
-    {
-    }
-    
-    /// Copy-construct from another vector.
-    Vector3(const Vector3& vector) :
-        x_(vector.x_),
-        y_(vector.y_),
-        z_(vector.z_)
-    {
-    }
-    
-    /// Construct from a two-dimensional vector and the Z coordinate.
-    Vector3(const Vector2& vector, float z) :
-        x_(vector.x_),
-        y_(vector.y_),
-        z_(z)
-    {
-    }
-    
-    /// Construct from coordinates.
-    Vector3(float x, float y, float z) :
-        x_(x),
-        y_(y),
-        z_(z)
-    {
-    }
-    
-    /// Test for equality with another vector without epsilon.
-    bool operator == (const Vector3& rhs) const { return x_ == rhs.x_ && y_ == rhs.y_ && z_ == rhs.z_; }
-    /// Add a vector.
-    Vector3 operator + (const Vector3& rhs) const { return Vector3(x_ + rhs.x_, y_ + rhs.y_, z_ + rhs.z_); }
-    /// Return negation.
-    Vector3 operator - () const { return Vector3(-x_, -y_, -z_); }
-    /// Subtract a vector.
-    Vector3 operator - (const Vector3& rhs) const { return Vector3(x_ - rhs.x_, y_ - rhs.y_, z_ - rhs.z_); }
-    /// Multiply with a scalar.
-    Vector3 operator * (float rhs) const { return Vector3(x_ * rhs, y_ * rhs, z_ * rhs); }
-    /// Multiply with a vector.
-    Vector3 operator * (const Vector3& rhs) const { return Vector3(x_ * rhs.x_, y_ * rhs.y_, z_ * rhs.z_); }
-    /// Divide by a scalar.
-    Vector3 operator / (float rhs) const { return Vector3(x_ / rhs, y_ / rhs, z_ / rhs); }
-    /// Divide by a vector.
-    Vector3 operator / (const Vector3& rhs) const { return Vector3(x_ / rhs.x_, y_ / rhs.y_, z_ / rhs.z_); }
+    Vector3();
+    Vector3(const Vector3& vector);
+    Vector3(const Vector2& vector, float z);
+    Vector3(float x, float y, float z);
+    
+    bool operator == (const Vector3& rhs) const;
+    Vector3 operator + (const Vector3& rhs) const;
+    Vector3 operator - () const;
+    Vector3 operator - (const Vector3& rhs) const;
+    Vector3 operator * (float rhs) const;
+    Vector3 operator * (const Vector3& rhs) const;
+    Vector3 operator / (float rhs) const;
     Vector3 operator / (const Vector3& rhs) const;
+    Vector3 operator / (const Vector3& rhs) const;
+    float Normalize();
+    float Length() const;
+    float LengthSquared() const;
+    float DotProduct(const Vector3& rhs) const;
+    float AbsDotProduct(const Vector3& rhs) const;
+    Vector3 CrossProduct(const Vector3& rhs) const;
+    Vector3 Abs() const;
+    Vector3 Lerp(const Vector3& rhs, float t) const;
+    bool Equals(const Vector3& rhs) const;
+    Vector3 Normalized() const;
     
-    /// Normalize to unit length and return the previous length.
-    float Normalize()
-    {
-        float len = Length();
-        if (len >= M_EPSILON)
-        {
-            float invLen = 1.0f / len;
-            x_ *= invLen;
-            y_ *= invLen;
-            z_ *= invLen;
-        }
-        
-        return len;
-    }
-    
-    /// Return length.
-    float Length() const { return sqrtf(x_ * x_ + y_ * y_ + z_ * z_); }
-    /// Return squared length.
-    float LengthSquared() const { return x_ * x_ + y_ * y_ + z_ * z_; }
-    /// Calculate dot product.
-    float DotProduct(const Vector3& rhs) const { return x_ * rhs.x_ + y_ * rhs.y_ + z_ * rhs.z_; }
-    /// Calculate absolute dot product.
-    float AbsDotProduct(const Vector3& rhs) const { return Urho3D::Abs(x_ * rhs.x_) + Urho3D::Abs(y_ * rhs.y_) + Urho3D::Abs(z_ * rhs.z_); }
-    
-    /// Calculate cross product.
-    Vector3 CrossProduct(const Vector3& rhs) const
-    {
-        return Vector3(
-            y_ * rhs.z_ - z_ * rhs.y_,
-            z_ * rhs.x_ - x_ * rhs.z_,
-            x_ * rhs.y_ - y_ * rhs.x_
-        );
-    }
-    
-    /// Return absolute vector.
-    Vector3 Abs() const { return Vector3(Urho3D::Abs(x_), Urho3D::Abs(y_), Urho3D::Abs(z_)); }
-    /// Linear interpolation with another vector.
-    Vector3 Lerp(const Vector3& rhs, float t) const { return *this * (1.0f - t) + rhs * t; }
-    /// Test for equality with another vector with epsilon.
-    bool Equals(const Vector3& rhs) const { return Urho3D::Equals(x_, rhs.x_) && Urho3D::Equals(y_, rhs.y_) && Urho3D::Equals(z_, rhs.z_); }
-    
-    /// Return normalized to unit length.
-    Vector3 Normalized() const
-    {
-        float len = Length();
-        if (len >= M_EPSILON)
-            return *this * (1.0f / len);
-        else
-            return *this;
-    }
-    
-    /// Return as string.
     String ToString() const;
     
-    /// X coordinate.
     float x_ @ x;
-    /// Y coordinate.
     float y_ @ y;
-    /// Z coordinate.
     float z_ @ z;
     
-    /// Zero vector.
     static const Vector3 ZERO;
-    /// (-1,0,0) vector.
     static const Vector3 LEFT;
-    /// (1,0,0) vector.
     static const Vector3 RIGHT;
-    /// (0,1,0) vector.
     static const Vector3 UP;
-    /// (0,-1,0) vector.
     static const Vector3 DOWN;
-    /// (0,0,1) vector.
     static const Vector3 FORWARD;
-    /// (0,0,-1) vector.
     static const Vector3 BACK;
-    /// (1,1,1) vector.
     static const Vector3 ONE;
 };

+ 17 - 67
Extras/LuaScript/pkgs/Math/Vector4.pkg

@@ -1,85 +1,35 @@
 $#include "Vector4.h"
 
-/// Four-dimensional vector.
 class Vector4
 {
-public:
-    /// Construct undefined.
-    Vector4()
-    {
-    }
-    
-    /// Copy-construct from another vector.
-    Vector4(const Vector4& vector) :
-        x_(vector.x_),
-        y_(vector.y_),
-        z_(vector.z_),
-        w_(vector.w_)
-    {
-    }
-    
-    /// Construct from a 3-dimensional vector and the W coordinate.
-    Vector4(const Vector3& vector, float w) :
-        x_(vector.x_),
-        y_(vector.y_),
-        z_(vector.z_),
-        w_(w)
-    {
-    }
-    
-    /// Construct from coordinates.
-    Vector4(float x, float y, float z, float w) :
-        x_(x),
-        y_(y),
-        z_(z),
-        w_(w)
-    {
-    }
-    
-    /// Test for equality with another vector without epsilon.
-    bool operator == (const Vector4& rhs) const { return x_ == rhs.x_ && y_ == rhs.y_ && z_ == rhs.z_ && w_ == rhs.w_; }
+    Vector4();
+    Vector4(const Vector4& vector);
+    Vector4(const Vector3& vector, float w);
+    Vector4(float x, float y, float z, float w);
 
-    /// Add a vector.
-    Vector4 operator + (const Vector4& rhs) const { return Vector4(x_ + rhs.x_, y_ + rhs.y_, z_ + rhs.z_, w_ + rhs.w_); }
-    /// Return negation.
-    Vector4 operator - () const { return Vector4(-x_, -y_, -z_, -w_); }
-    /// Subtract a vector.
-    Vector4 operator - (const Vector4& rhs) const { return Vector4(x_ - rhs.x_, y_ - rhs.y_, z_ - rhs.z_, w_ - rhs.w_); }
-    /// Multiply with a scalar.
-    Vector4 operator * (float rhs) const { return Vector4(x_ * rhs, y_ * rhs, z_ * rhs, w_ * rhs); }
-    /// Multiply with a vector.
-    Vector4 operator * (const Vector4& rhs) const { return Vector4(x_ * rhs.x_, y_ * rhs.y_, z_ * rhs.z_, w_ * rhs.w_); }
-    /// Divide by a scalar.
-    Vector4 operator / (float rhs) const { return Vector4(x_ / rhs, y_ / rhs, z_ / rhs, w_ / rhs); }
-    /// Divide by a vector.
-    Vector4 operator / (const Vector4& rhs) const { return Vector4(x_ / rhs.x_, y_ / rhs.y_, z_ / rhs.z_, w_ / rhs.w_); }
+    bool operator == (const Vector4& rhs) const;
+    Vector4 operator + (const Vector4& rhs) const;
+    Vector4 operator - () const;
+    Vector4 operator - (const Vector4& rhs) const;
+    Vector4 operator * (float rhs) const;
+    Vector4 operator * (const Vector4& rhs) const;
+    Vector4 operator / (float rhs) const;
+    Vector4 operator / (const Vector4& rhs) const;
     Vector4 operator / (const Vector4& rhs) const;
     
-    /// Calculate dot product.
-    float DotProduct(const Vector4& rhs) const { return x_ * rhs.x_ + y_ * rhs.y_ + z_ * rhs.z_ + w_ * rhs.w_; }
-    /// Calculate absolute dot product.
-    float AbsDotProduct(const Vector4& rhs) const { return Urho3D::Abs(x_ * rhs.x_) + Urho3D::Abs(y_ * rhs.y_) + Urho3D::Abs(z_ * rhs.z_) + Urho3D::Abs(w_ * rhs.w_); }
-    /// Return absolute vector.
-    Vector4 Abs() const { return Vector4(Urho3D::Abs(x_), Urho3D::Abs(y_), Urho3D::Abs(z_), Urho3D::Abs(w_)); }
-    /// Linear interpolation with another vector.
-    Vector4 Lerp(const Vector4& rhs, float t) const { return *this * (1.0f - t) + rhs * t; }
-    /// Test for equality with another vector with epsilon.
-    bool Equals(const Vector4& rhs) const { return Urho3D::Equals(x_, rhs.x_) && Urho3D::Equals(y_, rhs.y_) && Urho3D::Equals(z_, rhs.z_) && Urho3D::Equals(w_, rhs.w_); }
+    float DotProduct(const Vector4& rhs) const;
+    float AbsDotProduct(const Vector4& rhs) const;
+    Vector4 Abs() const;
+    Vector4 Lerp(const Vector4& rhs, float t) const;
+    bool Equals(const Vector4& rhs) const;
 
-    /// Return as string.
     String ToString() const;
     
-    /// X coordinate.
     float x_ @ x;
-    /// Y coordinate.
     float y_ @ y;
-    /// Z coordinate.
     float z_ @ z;
-    /// W coordinate.
     float w_ @ w;
     
-    /// Zero vector.
     static const Vector4 ZERO;
-    /// (1,1,1) vector.
     static const Vector4 ONE;
 };