JPL Spatial
Sound spatialization and propagation library
Loading...
Searching...
No Matches
SpecularPath.h
Go to the documentation of this file.
1//
2// ██╗██████╗ ██╗ ██╗██████╗ ███████╗
3// ██║██╔══██╗ ██║ ██║██╔══██╗██╔════╝ ** JPLSpatial **
4// ██║██████╔╝ ██║ ██║██████╔╝███████╗
5// ██ ██║██╔═══╝ ██║ ██║██╔══██╗╚════██║ https://github.com/Jaytheway/JPLSpatial
6// ╚█████╔╝██║ ███████╗██║██████╔╝███████║
7// ╚════╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
8//
9// Copyright Jaroslav Pevno, JPLSpatial is offered under the terms of the ISC license:
10//
11// Permission to use, copy, modify, and/or distribute this software for any purpose with or
12// without fee is hereby granted, provided that the above copyright notice and this permission
13// notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
14// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
16// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#pragma once
21
22#include "JPLSpatial/Core.h"
27
28#include <span>
29
30namespace JPL
31{
33
34 //======================================================================
37 // TODO: we may or may not want to keep id list for the entire path
38 // to check for source/listener matches
40 {
42
43 // If the RISM is implemented as a depth-first ray traversal,
44 // the path identifier can be efficiently incrementally
45 // constructed with each successive ray reflection.
46 JPL_INLINE constexpr void AddVertex(uint32 id) { HashCombine32(Id, id); }
47
48 JPL_INLINE constexpr void FinalizeHash() { Id = Murmur3Finalize(Id); }
49
50 // TODO: we may want to call FinalizeHash when comparing, or when converting to std::hash
51 [[nodiscard]] constexpr bool operator==(const SpecularPathId&) const = default;
52 };
53
54 //======================================================================
55 template<CVec3 Vec3Type>
57 {
58 // Sequence of identifiers of source, surfaces, and listener
59 std::span<int> Nodes; // { source, s0, s1..., listener }
61
62 // Combined energy intencity dB loss
64
65 // IS position or direction
66 Vec3Type ImageSource;
67
68 bool bValid;
69 };
70
71} // namespace JPL
72
73
74namespace std
75{
76 template <>
77 struct hash<JPL::SpecularPathId>
78 {
79 [[nodiscard]] constexpr std::size_t operator()(const JPL::SpecularPathId& key) const
80 {
81 return static_cast<std::size_t>(key.Id);
82 }
83 };
84} // namespace std
Definition AcousticMaterial.h:36
JPL_INLINE constexpr void HashCombine32(uint32_t &seed, uint32_t id32)
Definition Hash.h:42
std::uint32_t uint32
Definition Core.h:311
JPL_INLINE constexpr uint32_t Murmur3Finalize(uint32_t hash)
Definition Hash.h:59
JPL_INLINE simd min(const simd &a, const simd &b) noexcept
Element-wise min.
Definition SIMD.h:1813
Definition ChannelMap.h:268
static constexpr uint32_t cStartSeed
Definition Hash.h:31
Definition SpecularPath.h:57
EnergyBands Energy
Note: memory is owned by SpecularPathCache object.
Definition SpecularPath.h:63
Vec3Type ImageSource
Definition SpecularPath.h:66
std::span< int > Nodes
Definition SpecularPath.h:59
bool bValid
Definition SpecularPath.h:68
A very experimental specular path definition.
Definition SpecularPath.h:40
uint32 Id
Definition SpecularPath.h:41
constexpr bool operator==(const SpecularPathId &) const =default
JPL_INLINE constexpr void AddVertex(uint32 id)
Definition SpecularPath.h:46
JPL_INLINE constexpr void FinalizeHash()
Definition SpecularPath.h:48
Minimal 4-wide 32-bit float vector implementation for SIMD.
Definition SIMD.h:60
constexpr std::size_t operator()(const JPL::SpecularPathId &key) const
Definition SpecularPath.h:79