Skip to content

Commit

Permalink
Cleanup: Post merge
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 5, 2020
1 parent bb999de commit 0c040b5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions doomsday/libs/core/include/de/core/slope.h
Expand Up @@ -26,15 +26,15 @@ namespace de {
* Combination of a yaw angle and Z slope at an XY distance of 1.0 units.
* @ingroup math
*/
struct DENG2_PUBLIC Slope
struct DE_PUBLIC Slope
{
float angle; // radians
float slope;

Slope(float angle = 0.0f, float slope = 0.0f);
Vector3f toUnitVec() const;
Vec3f toUnitVec() const;

static Slope fromVec(const Vector3f &vector);
static Slope fromVec(const Vec3f &vector);
};

} // namespace de
9 changes: 9 additions & 0 deletions doomsday/libs/core/include/de/data/hash.h
Expand Up @@ -20,6 +20,7 @@
#define LIBCORE_HASH_H

#include <unordered_map>
#include <list>
#include "../libcore.h"

namespace de {
Expand Down Expand Up @@ -48,6 +49,7 @@ class Hash : public std::unordered_map<Key, Value, HashFn, KeyEqual>

using iterator = typename Base::iterator;
using const_iterator = typename Base::const_iterator;
using value_type = typename Base::value_type;

using Base::begin;
using Base::empty;
Expand Down Expand Up @@ -97,6 +99,13 @@ class Hash : public std::unordered_map<Key, Value, HashFn, KeyEqual>
{
for (auto &i : *this) { delete i.second; }
}

std::list<Key> keys() const
{
return map<std::list<Key>>(*this, [](const value_type &v) {
return v.first;
});
}
};

template <typename Key,
Expand Down
8 changes: 4 additions & 4 deletions doomsday/libs/core/src/core/slope.cpp
Expand Up @@ -27,20 +27,20 @@ Slope::Slope(float angle, float slope)
, slope(slope)
{}

Vector3f Slope::toUnitVec() const
Vec3f Slope::toUnitVec() const
{
return Vector3f(std::cos(angle), std::sin(angle), slope).normalize();
return Vec3f(std::cos(angle), std::sin(angle), slope).normalize();
}

Slope Slope::fromVec(const Vector3f &vector)
Slope Slope::fromVec(const Vec3f &vector)
{
const auto vec = vector.normalize();
if (fequal(vec.x, 0.0f) && fequal(vec.y, 0.0f))
{
return {0.0f, vec.z > 0 ? std::numeric_limits<float>::max() :
std::numeric_limits<float>::min()};
}
return {atan2(vec.y, vec.x), float(vec.z / vec.xy().length())};
return {std::atan2(vec.y, vec.x), float(vec.z / vec.xy().length())};
}

} // namespace de
2 changes: 1 addition & 1 deletion doomsday/libs/core/src/scripting/bindings_math.cpp
Expand Up @@ -59,7 +59,7 @@ void initMathModule(Binder &binder, Record &mathModule)
{
binder.init(mathModule)
<< DE_FUNC_NOARG(Math_Random, "random")
<< DE_FUNC (Math_RandInt, "randInt", "low" << "high");
<< DE_FUNC (Math_RandInt, "randInt", "low" << "high")
<< DE_FUNC (Math_RandNum, "randNum", "low" << "high")
<< DE_FUNC (Math_Cos, "cos", "radians")
<< DE_FUNC (Math_Sin, "sin", "radians")
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libs/core/src/scripting/nameexpression.cpp
Expand Up @@ -177,15 +177,15 @@ Value *NameExpression::evaluate(Evaluator &evaluator) const
}

// Look up the rest in relation to what was already found.
for (int i = 2; i < d->identifierSequence.size(); ++i)
for (int i = 2; i < d->identifierSequence.sizei(); ++i)
{
if (!variable)
{
throw NotFoundError("NameExpression::evaluate",
"Scope '" + identifier + "' not found");
}
identifier = d->identifierSequence.at(i);
}
variable = d->findInRecord(identifier, variable->valueAsRecord(), foundInNamespace);
variable = d->findInRecord(identifier, variable->valueAsRecord(), foundInNamespace);
}

if (flags().testFlag(ThrowawayIfInScope) && variable)
Expand Down

0 comments on commit 0c040b5

Please sign in to comment.