Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
TileRing.h
Go to the documentation of this file.
1// Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
2//
3// TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
4// *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
5// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,IMPLIED WARRANTIES OF
6// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
7// OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT, OR
8// CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS
9// OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY
10// OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
11// EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
12//
13// Please direct any bugs or questions to SDKFeedback@nvidia.com
14
15//----------------------------------------------------------------------------------
16// Defines and draws one ring of tiles in a concentric, nested set of rings. Each ring
17// is a different LOD and uses a different tile/patch size. These are actually square
18// rings. (Is there a term for that?) But they could conceivably change to circular.
19// The inner-most LOD is a square, represented by a degenerate ring.
20//
21
22/*
23Copyright (c) 2018 DIVIDE-Studio
24Copyright (c) 2009 Ionut Cava
25
26This file is part of DIVIDE Framework.
27
28Permission is hereby granted, free of charge, to any person obtaining a copy of
29this software
30and associated documentation files (the "Software"), to deal in the Software
31without restriction,
32including without limitation the rights to use, copy, modify, merge, publish,
33distribute, sublicense,
34and/or sell copies of the Software, and to permit persons to whom the Software
35is furnished to do so,
36subject to the following conditions:
37
38The above copyright notice and this permission notice shall be included in all
39copies or substantial portions of the Software.
40
41THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42IMPLIED,
43INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
44PARTICULAR PURPOSE AND NONINFRINGEMENT.
45IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
46DAMAGES OR OTHER LIABILITY,
47WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48CONNECTION WITH THE SOFTWARE
49OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50
51*/
52
53#pragma once
54#ifndef DVD_TILE_RING_H_
55#define DVD_TILE_RING_H_
56
57namespace Divide {
58
59// Int dimensions specified to the ctor are in numbers of tiles. It's symmetrical in
60// each direction. (Don't read much into the exact numbers of #s in this diagram.)
61//
62// <- outerWidth ->
63// ###################
64// ###################
65// ### ###
66// ###<-holeWidth->###
67// ### ###
68// ### (0,0) ###
69// ### ###
70// ### ###
71// ### ###
72// ###################
73// ###################
74//
75class TileRing final
76{
77public:
78 struct Adjacency
79 {
80 // These are the size of the neighbours along +/- x or y axes.
81 // For interior tiles this is 1. For edge tiles it is 0.5 or 2.0.
86 };
87
89 {
90 F32 positionX = 0.0f;
91 F32 positionZ = 0.0f;
92 F32 tileScale = 1.0f;
93 F32 ringID = 0.0f;
94 };
95
97 {
100 };
101
102public:
103 // holeWidth & outerWidth are nos. of tiles; tileSize is a world-space length
104 explicit TileRing(I32 holeWidth, I32 outerWidth, F32 tileSize) noexcept;
105
106 PROPERTY_R(I32, tileCount, 0);
107 PROPERTY_R(F32, tileSize, 1.f);
108
109 // We use ID as a really hacky LoD system. Ring 0 => LoD 0. Ring 1 => LoD 1 (e.g. no detail normals), etc
110 [[nodiscard]] vector<InstanceData> createInstanceDataVB(I32 ringID);
111
112private:
113 [[nodiscard]] bool InRing(I32 x, I32 y) const noexcept;
114 void AssignNeighbourSizes(I32 x, I32 y, Adjacency*) const noexcept;
115
116private:
117 const I32 _holeWidth = 0;
118 const I32 _outerWidth = 0;
119 const I32 _ringWidth = 0;
120};
121
122} // namespace Divide
123
124#endif //DVD_TILE_RING_H_
PROPERTY_R(F32, tileSize, 1.f)
PROPERTY_R(I32, tileCount, 0)
const I32 _ringWidth
Definition: TileRing.h:119
void AssignNeighbourSizes(I32 x, I32 y, Adjacency *) const noexcept
Definition: TileRing.cpp:40
const I32 _holeWidth
Definition: TileRing.h:117
const I32 _outerWidth
Definition: TileRing.h:118
vector< InstanceData > createInstanceDataVB(I32 ringID)
Definition: TileRing.cpp:98
bool InRing(I32 x, I32 y) const noexcept
Definition: TileRing.cpp:33
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
int32_t I32
eastl::vector< Type > vector
Definition: Vector.h:42