Wrap the Vector operators for C#
This should allow all the normal vector operations as well as silence the warnings from SWIG.
This commit is contained in:
parent
e90215b0fc
commit
bab3c32ec5
@ -12,6 +12,13 @@ PROPERTY(PolyVox::Vector, y, getY, setY)
|
||||
PROPERTY(PolyVox::Vector, z, getZ, setZ)
|
||||
#endif
|
||||
|
||||
%rename(Plus) operator +;
|
||||
%rename(Minus) operator -;
|
||||
%rename(Multiply) operator *;
|
||||
%rename(Divide) operator /;
|
||||
%rename(Equal) operator ==;
|
||||
%rename(NotEqual) operator !=;
|
||||
|
||||
%extend PolyVox::Vector {
|
||||
#ifdef SWIGPYTHON
|
||||
PolyVox::Vector __add__(const PolyVox::Vector& rhs) {
|
||||
@ -44,6 +51,56 @@ PROPERTY(PolyVox::Vector, z, getZ, setZ)
|
||||
//%csattributes PolyVox::Vector::operator< "[System.Obsolete(\"deprecated\")]"
|
||||
|
||||
%define VECTOR3(StorageType,OperationType,ReducedStorageType)
|
||||
#if SWIGCSHARP
|
||||
%extend PolyVox::Vector<3,StorageType,OperationType> {
|
||||
PolyVox::Vector<3,StorageType,OperationType> operator+(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self + rhs;}
|
||||
PolyVox::Vector<3,StorageType,OperationType> operator-(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self - rhs;}
|
||||
PolyVox::Vector<3,StorageType,OperationType> operator*(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self * rhs;}
|
||||
PolyVox::Vector<3,StorageType,OperationType> operator/(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self / rhs;}
|
||||
PolyVox::Vector<3,StorageType,OperationType> operator*(const StorageType& rhs) {return *$self * rhs;}
|
||||
PolyVox::Vector<3,StorageType,OperationType> operator/(const StorageType& rhs) {return *$self / rhs;}
|
||||
};
|
||||
%typemap(cscode) PolyVox::Vector<3,StorageType,OperationType> %{
|
||||
public static Vector3D##StorageType operator+(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||
newVec = lhs.Plus(rhs);
|
||||
return newVec;
|
||||
}
|
||||
public static Vector3D##StorageType operator-(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||
newVec = lhs.Minus(rhs);
|
||||
return newVec;
|
||||
}
|
||||
public static Vector3D##StorageType operator*(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||
newVec = lhs.Multiply(rhs);
|
||||
return newVec;
|
||||
}
|
||||
public static Vector3D##StorageType operator/(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||
newVec = lhs.Divide(rhs);
|
||||
return newVec;
|
||||
}
|
||||
public static Vector3D##StorageType operator*(Vector3D##StorageType lhs, $typemap(cstype, StorageType) rhs) {
|
||||
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||
newVec = lhs.Multiply(rhs);
|
||||
return newVec;
|
||||
}
|
||||
public static Vector3D##StorageType operator/(Vector3D##StorageType lhs, $typemap(cstype, StorageType) rhs) {
|
||||
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||
newVec = lhs.Divide(rhs);
|
||||
return newVec;
|
||||
}
|
||||
public bool Equals(Vector3D##StorageType rhs) {
|
||||
if ((object)rhs == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Equal(rhs);
|
||||
}
|
||||
%}
|
||||
%ignore PolyVox::Vector<3,StorageType,OperationType>::operator<; //This is deprecated
|
||||
#endif
|
||||
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType,ReducedStorageType,ReducedStorageType);
|
||||
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType);
|
||||
%ignore PolyVox::Vector<3,StorageType,OperationType>::getW() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user