This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool Intersect(const Frustum& frustum, const AABB& aabb) | |
{ | |
for (int plane_idx = 0; plane_idx < 6; ++plane_idx) | |
{ | |
std::uint8_t plane_in = 0; | |
std::uint8_t plane_out = 0; | |
for (int x_idx = 0; x_idx < 2; ++x_idx) | |
{ | |
for (int y_idx = 0; y_idx < 2; ++y_idx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vec3f GetPointPositive(const AABB& a, const Vec3f& v) | |
{ | |
Vec3f ret( | |
(v.x > 0 ? a.max.x : a.min.x), | |
(v.y > 0 ? a.max.y : a.min.y), | |
(v.z > 0 ? a.max.z : a.min.z) | |
); | |
return ret; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool IsIntersect(const AABB& a, const AABB& b) | |
{ | |
for(int i=0;i<3;++i) | |
{ | |
if(a.min[i] <= b.max[i] && a.max[i] <= b.min[i]) | |
return true; | |
} | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "object_factory.hpp" | |
class DerivedObject : public Object | |
{ | |
public: | |
DerivedObject::DerivedObject() | |
{ | |
// some code | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ObjectFactory | |
{ | |
public: | |
using ObjectFactoryFunctionType = Object*(*)(); | |
using FactoryMapType = std::unordered_map<std::string, ObjectFactoryFunctionType>; | |
FactoryMapType factory_map; | |
Object* Create(const std::string& type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct IntersectResult | |
{ | |
float t; | |
bool hit; | |
IntersectResult() = default; | |
IntersectResult(bool a_hit, float a_t) : hit(a_hit), t(a_t) {} | |
}; | |
IntersectResult Intersect(const Ray& ray, const Plane& plane) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline int nextPow2(int n) | |
{ | |
n--; | |
n |= n >> 1; | |
n |= n >> 2; | |
n |= n >> 4; | |
n |= n >> 8; | |
n |= n >> 16; | |
n++; | |
return n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2013 Calvin Rien | |
* | |
* Based on the JSON parser by Patrick van Bergen | |
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html | |
* | |
* Simplified it so that it doesn't throw exceptions | |
* and can be used in Unity iPhone with maximum code stripping. | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining |