Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Sparky-core/SparkyCore-TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
- Better logging. Seriously.
- Check for memory leaks. Likely.
- Some kind of Asset Server. This needs to support things like memory mapping and virtual file systems.
- Hash functions for maths classes
- Raw Input instead of Win32 stuff
13 changes: 12 additions & 1 deletion Sparky-core/src/sp/maths/AABB.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ namespace sp { namespace maths {
friend std::ostream& operator<<(std::ostream& stream, const AABB& aabb);
};

} }
} }

namespace std {
template<>
struct hash<sp::maths::AABB>
{
size_t operator()(const sp::maths::AABB& value) const
{
return std::hash<sp::maths::vec3>()(value.min) ^ std::hash<sp::maths::vec3>()(value.max);
}
};
}
14 changes: 13 additions & 1 deletion Sparky-core/src/sp/maths/Quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,16 @@ namespace sp { namespace maths {

};

} }
} }

namespace std {
template<>
struct hash<sp::maths::Quaternion>
{
size_t operator()(const sp::maths::Quaternion& value) const
{
return std::hash<float>()(value.x) ^ std::hash<float>()(value.y)
^ std::hash<float>()(value.z) ^ std::hash<float>()(value.w);
}
};
}
14 changes: 13 additions & 1 deletion Sparky-core/src/sp/maths/Rectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,16 @@ namespace sp { namespace maths {
friend std::ostream& operator<<(std::ostream& stream, const Rectangle& Rectangle);
};

} }
} }

namespace std {
template<>
struct hash<sp::maths::Rectangle>
{
size_t operator()(const sp::maths::Rectangle& value) const
{
return std::hash<float>()(value.x) ^ std::hash<float>()(value.y)
^ std::hash<float>()(value.width) ^ std::hash<float>()(value.height);
}
};
}
14 changes: 13 additions & 1 deletion Sparky-core/src/sp/maths/mat4.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,16 @@ namespace sp { namespace maths {
String ToString() const;
};

} }
} }

namespace std {
template<>
struct hash<sp::maths::mat4>
{
size_t operator()(const sp::maths::mat4& value) const
{
return std::hash<sp::maths::vec4>()(value.rows[0]) ^ std::hash<sp::maths::vec4>()(value.rows[1])
^ std::hash<sp::maths::vec4>()(value.rows[2]) ^ std::hash<sp::maths::vec4>()(value.rows[3]);
}
};
}
13 changes: 12 additions & 1 deletion Sparky-core/src/sp/maths/vec2.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,15 @@ namespace sp { namespace maths {
friend std::ostream& operator<<(std::ostream& stream, const vec2& vector);
};

} }
} }

namespace std {
template<>
struct hash<sp::maths::vec2>
{
size_t operator()(const sp::maths::vec2& value) const
{
return std::hash<float>()(value.x) ^ std::hash<float>()(value.y);
}
};
}
13 changes: 12 additions & 1 deletion Sparky-core/src/sp/maths/vec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,15 @@ namespace sp { namespace maths {
friend std::ostream& operator<<(std::ostream& stream, const vec3& vector);
};

} }
} }

namespace std {
template<>
struct hash<sp::maths::vec3>
{
size_t operator()(const sp::maths::vec3& value) const
{
return std::hash<float>()(value.x) ^ std::hash<float>()(value.y) ^ std::hash<float>()(value.z);
}
};
}
4 changes: 2 additions & 2 deletions Sparky-core/src/sp/maths/vec4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ namespace sp { namespace maths {
return Divide(other);
}

bool vec4::operator==(const vec4& other)
bool vec4::operator==(const vec4& other) const
{
return x == other.x && y == other.y && z == other.z && w == other.w;
}

bool vec4::operator!=(const vec4& other)
bool vec4::operator!=(const vec4& other) const
{
return !(*this == other);
}
Expand Down
18 changes: 15 additions & 3 deletions Sparky-core/src/sp/maths/vec4.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace sp { namespace maths {
friend vec4 operator*(vec4 left, const vec4& right);
friend vec4 operator/(vec4 left, const vec4& right);

bool operator==(const vec4& other);
bool operator!=(const vec4& other);
bool operator==(const vec4& other) const;
bool operator!=(const vec4& other) const;

vec4& operator+=(const vec4& other);
vec4& operator-=(const vec4& other);
Expand All @@ -43,4 +43,16 @@ namespace sp { namespace maths {
friend std::ostream& operator<<(std::ostream& stream, const vec4& vector);
};

} }
} }

namespace std {
template<>
struct hash<sp::maths::vec4>
{
size_t operator()(const sp::maths::vec4& value) const
{
return std::hash<float>()(value.x) ^ std::hash<float>()(value.y)
^ std::hash<float>()(value.z) ^ std::hash<float>()(value.w);
}
};
}