-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathModel.cpp
95 lines (80 loc) · 3.29 KB
/
Model.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// ======================================================================== //
// Copyright 2022-2022 Stefan Zellmann //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ======================================================================== //
#include "Model.h"
namespace exa {
Model::~Model()
{
}
void Model::setNumGridCells(const vec3i numMCs)
{
if (grid != nullptr) {
throw std::runtime_error("must set num grid cells before calling initGPU!");
}
grid = std::make_shared<Grid>();
grid->dims = numMCs;
}
void Model::setVoxelSpaceTransform(const box3f remap_from, const box3f remap_to)
{
affine3f voxelSpaceCoordSys
= affine3f::translate(remap_from.lower)
* affine3f::scale(remap_from.span());
affine3f worldSpaceCoordSys
= affine3f::translate(remap_to.lower)
* affine3f::scale(remap_to.span());
voxelSpaceTransform
= voxelSpaceCoordSys
* rcp(worldSpaceCoordSys);
}
box3f Model::getBounds() const
{
box3f bounds = cellBounds;
bounds.lower = xfmPoint(rcp(voxelSpaceTransform),bounds.lower);
bounds.upper = xfmPoint(rcp(voxelSpaceTransform),bounds.upper);
#ifdef EXA_STITCH_MIRROR_EXAJET
const affine3f &tfm = (const affine3f &)mirrorTransform;
vec3f lower = xfmPoint(tfm,cellBounds.lower);
vec3f upper = xfmPoint(tfm,cellBounds.upper);
box3f mirrorBounds{
min(lower,upper),
max(lower,upper)
};
mirrorBounds.lower = xfmPoint(rcp(voxelSpaceTransform),mirrorBounds.lower);
mirrorBounds.upper = xfmPoint(rcp(voxelSpaceTransform),mirrorBounds.upper);
bounds.extend(mirrorBounds);
#endif
return bounds;
}
/* This codes makes assumptions that are only useful
for exajet; we eventually want to move mirroring/other
scene graph functionalilty out of the model class and
make the renderer responsible for performing these */
#ifdef EXA_STITCH_MIRROR_EXAJET
void Model::initMirrorExajet()
{
affine3f transform =
affine3f::translate(cellBounds.upper)
* affine3f::scale(vec3f(1,-1,1))
* affine3f::translate(-cellBounds.upper);
owl4x3f tfm;
tfm.t = owl3f{0.f, transform.p.y, 0.f};
tfm.vx = owl3f{1.f, 0.f, 0.f};
tfm.vy = owl3f{0.f, transform.l.vy.y, 0.f};
tfm.vz = owl3f{0.f, 0.f, 1.f};
mirrorTransform = tfm;
}
#endif
} // ::exa
// vim: sw=2:expandtab:softtabstop=2:ts=2:cino=\:0g0t0