You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
|
2 days ago
|
#pragma once
|
||
|
|
|
||
|
|
#include <base/subface.hpp>
|
||
|
|
#include <primitive_descriptor.h>
|
||
|
|
|
||
|
|
namespace internal
|
||
|
|
{
|
||
|
|
// local: a sphere with center at (0, 0, 0) and radius 1
|
||
|
|
// u: planar angle from x-axis to z-axis
|
||
|
|
// v: polar angle from xz-plane to y-axis
|
||
|
|
// EDIT: recap v from [-pi/2, pi/2] to [0, pi]
|
||
|
|
struct sphere_face_t final : subface {
|
||
|
|
const sphere_descriptor_t* geometry_ptr = nullptr;
|
||
|
|
|
||
|
|
const sphere_descriptor_t* get_geometry_ptr() const
|
||
|
|
{
|
||
|
|
printf("[WARNING] sphere_face_t::descriptor() called, but sphere has no descriptor!\n");
|
||
|
|
return nullptr;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
} // namespace internal
|
||
|
|
|
||
|
|
namespace detail
|
||
|
|
{
|
||
|
|
template <>
|
||
|
|
struct hasher<internal::sphere_face_t> {
|
||
|
|
size_t operator()(const internal::sphere_face_t& subface) const { return hash_funcs(subface.local_to_world); }
|
||
|
|
};
|
||
|
|
|
||
|
|
template <>
|
||
|
|
struct eq_compare<internal::sphere_face_t> {
|
||
|
|
bool operator()(const internal::sphere_face_t& lhs, const internal::sphere_face_t& rhs) const
|
||
|
|
{
|
||
|
|
//return eq_funcs(lhs.local_to_world, rhs.local_to_world);
|
||
|
|
|
||
|
|
constexpr double eps = 1e-12;
|
||
|
|
bool matrix_eq = lhs.world_to_local.isApprox(rhs.world_to_local, eps);
|
||
|
|
return matrix_eq;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
} // namespace detail
|