Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ClipPlanes.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_CLIP_PLANES_H_
34#define DVD_CLIP_PLANES_H_
35
36namespace Divide {
37 enum class ClipPlaneIndex : U8 {
38 CLIP_PLANE_0 = 0,
44 COUNT
45 };
46
47 template<size_t N>
49 void resetAll() {
50 _planeState.fill(false);
51 }
52
53 void set(U32 index, const Plane<F32>& plane) noexcept {
54 assert(index < N);
55
56 _planes[index] = plane;
57 _planeState[index] = true;
58 }
59
60 void reset(U32 index) {
61 assert(index < N);
62 _planeState[index] = false;
63 }
64
65 bool operator==(const ClipPlaneList& rhs) const noexcept {
66 return _planeState == rhs._planeState &&
67 _planes == rhs._planes;
68 }
69
70 bool operator!=(const ClipPlaneList& rhs) const {
71 return _planeState != rhs._planeState ||
72 _planes != rhs._planes;
73 }
74
75 [[nodiscard]] const PlaneList<N>& planes() const noexcept { return _planes; }
76 [[nodiscard]] const std::array<bool, N>& planeState() const noexcept { return _planeState; }
77
78 private:
80 std::array<bool, N> _planeState = create_array<N, bool>(false);
81 };
82
84}; //namespace Divide
85
86#endif //DVD_CLIP_PLANES_H_
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::array< Plane< F32 >, N > PlaneList
Definition: Plane.h:189
uint8_t U8
ClipPlaneIndex
Definition: ClipPlanes.h:37
uint32_t U32
constexpr auto to_base(const Type value) -> Type
std::array< bool, N > _planeState
Definition: ClipPlanes.h:80
bool operator!=(const ClipPlaneList &rhs) const
Definition: ClipPlanes.h:70
void set(U32 index, const Plane< F32 > &plane) noexcept
Definition: ClipPlanes.h:53
const std::array< bool, N > & planeState() const noexcept
Definition: ClipPlanes.h:76
const PlaneList< N > & planes() const noexcept
Definition: ClipPlanes.h:75
PlaneList< N > _planes
Definition: ClipPlanes.h:79
void reset(U32 index)
Definition: ClipPlanes.h:60
bool operator==(const ClipPlaneList &rhs) const noexcept
Definition: ClipPlanes.h:65