Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
b25c9b1b
P
pbrt-v4
项目概览
imjiangjun
/
pbrt-v4
12 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pbrt-v4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b25c9b1b
编写于
11月 13, 2020
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SampledGrid: take optional convert callback
上级
4a02dd47
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
40 deletion
+50
-40
src/pbrt/util/containers.h
src/pbrt/util/containers.h
+50
-40
未找到文件。
src/pbrt/util/containers.h
浏览文件 @
b25c9b1b
...
...
@@ -750,27 +750,67 @@ class SampledGrid {
const_iterator
begin
()
const
{
return
values
.
begin
();
}
const_iterator
end
()
const
{
return
values
.
end
();
}
PBRT_CPU_GPU
T
Lookup
(
const
Point3f
&
p
)
const
{
template
<
typename
F
>
PBRT_CPU_GPU
auto
Lookup
(
const
Point3f
&
p
,
F
convert
)
const
{
// Compute voxel coordinates and offsets for _p_
Point3f
pSamples
(
p
.
x
*
nx
-
.5
f
,
p
.
y
*
ny
-
.5
f
,
p
.
z
*
nz
-
.5
f
);
Point3i
pi
=
(
Point3i
)
Floor
(
pSamples
);
Vector3f
d
=
pSamples
-
(
Point3f
)
pi
;
// Return trilinearly interpolated voxel values
T
d00
=
Lerp
(
d
.
x
,
Lookup
(
pi
),
Lookup
(
pi
+
Vector3i
(
1
,
0
,
0
)));
T
d10
=
Lerp
(
d
.
x
,
Lookup
(
pi
+
Vector3i
(
0
,
1
,
0
)),
Lookup
(
pi
+
Vector3i
(
1
,
1
,
0
)));
T
d01
=
Lerp
(
d
.
x
,
Lookup
(
pi
+
Vector3i
(
0
,
0
,
1
)),
Lookup
(
pi
+
Vector3i
(
1
,
0
,
1
)));
T
d11
=
Lerp
(
d
.
x
,
Lookup
(
pi
+
Vector3i
(
0
,
1
,
1
)),
Lookup
(
pi
+
Vector3i
(
1
,
1
,
1
)));
T
d0
=
Lerp
(
d
.
y
,
d00
,
d10
);
T
d1
=
Lerp
(
d
.
y
,
d01
,
d11
);
auto
d00
=
Lerp
(
d
.
x
,
Lookup
(
pi
,
convert
),
Lookup
(
pi
+
Vector3i
(
1
,
0
,
0
),
convert
));
auto
d10
=
Lerp
(
d
.
x
,
Lookup
(
pi
+
Vector3i
(
0
,
1
,
0
),
convert
),
Lookup
(
pi
+
Vector3i
(
1
,
1
,
0
),
convert
));
auto
d01
=
Lerp
(
d
.
x
,
Lookup
(
pi
+
Vector3i
(
0
,
0
,
1
),
convert
),
Lookup
(
pi
+
Vector3i
(
1
,
0
,
1
),
convert
));
auto
d11
=
Lerp
(
d
.
x
,
Lookup
(
pi
+
Vector3i
(
0
,
1
,
1
),
convert
),
Lookup
(
pi
+
Vector3i
(
1
,
1
,
1
),
convert
));
auto
d0
=
Lerp
(
d
.
y
,
d00
,
d10
);
auto
d1
=
Lerp
(
d
.
y
,
d01
,
d11
);
return
Lerp
(
d
.
z
,
d0
,
d1
);
}
PBRT_CPU_GPU
T
Lookup
(
const
Point3i
&
p
)
const
;
T
Lookup
(
const
Point3f
&
p
)
const
{
return
Lookup
(
p
,
[]
PBRT_CPU_GPU
(
T
value
)
{
return
value
;
});
}
template
<
typename
F
>
PBRT_CPU_GPU
auto
Lookup
(
const
Point3i
&
p
,
F
convert
)
const
{
Bounds3i
sampleBounds
(
Point3i
(
0
,
0
,
0
),
Point3i
(
nx
,
ny
,
nz
));
if
(
!
InsideExclusive
(
p
,
sampleBounds
))
return
convert
(
T
{});
return
convert
(
values
[(
p
.
z
*
ny
+
p
.
y
)
*
nx
+
p
.
x
]);
}
PBRT_CPU_GPU
T
Lookup
(
const
Point3i
&
p
)
const
{
return
Lookup
(
p
,
[]
PBRT_CPU_GPU
(
T
value
)
{
return
value
;
});
}
template
<
typename
F
>
Float
MaximumValue
(
const
Bounds3f
&
bounds
,
F
convert
)
const
{
Point3f
ps
[
2
]
=
{
Point3f
(
bounds
.
pMin
.
x
*
nx
-
.5
f
,
bounds
.
pMin
.
y
*
ny
-
.5
f
,
bounds
.
pMin
.
z
*
nz
-
.5
f
),
Point3f
(
bounds
.
pMax
.
x
*
nx
-
.5
f
,
bounds
.
pMax
.
y
*
ny
-
.5
f
,
bounds
.
pMax
.
z
*
nz
-
.5
f
)};
Point3i
pi
[
2
]
=
{
Max
(
Point3i
(
Floor
(
ps
[
0
])),
Point3i
(
0
,
0
,
0
)),
Min
(
Point3i
(
Floor
(
ps
[
1
]))
+
Vector3i
(
1
,
1
,
1
),
Point3i
(
nx
-
1
,
ny
-
1
,
nz
-
1
))};
Float
maxValue
=
Lookup
(
Point3i
(
pi
[
0
]),
convert
);
for
(
int
z
=
pi
[
0
].
z
;
z
<=
pi
[
1
].
z
;
++
z
)
for
(
int
y
=
pi
[
0
].
y
;
y
<=
pi
[
1
].
y
;
++
y
)
for
(
int
x
=
pi
[
0
].
x
;
x
<=
pi
[
1
].
x
;
++
x
)
maxValue
=
std
::
max
(
maxValue
,
Lookup
(
Point3i
(
x
,
y
,
z
),
convert
));
T
MaximumValue
(
const
Bounds3f
&
bounds
)
const
;
return
maxValue
;
}
T
MaximumValue
(
const
Bounds3f
&
bounds
)
const
{
return
MaximumValue
(
bounds
,
[](
T
value
)
{
return
value
;
});
}
std
::
string
ToString
()
const
{
return
StringPrintf
(
"[ SampledGrid nx: %d ny: %d nz: %d values: %s ]"
,
nx
,
ny
,
nz
,
...
...
@@ -783,36 +823,6 @@ class SampledGrid {
int
nx
,
ny
,
nz
;
};
// SampledGrid Inline Methods
template
<
typename
T
>
PBRT_CPU_GPU
inline
T
SampledGrid
<
T
>::
Lookup
(
const
Point3i
&
p
)
const
{
Bounds3i
sampleBounds
(
Point3i
(
0
,
0
,
0
),
Point3i
(
nx
,
ny
,
nz
));
if
(
!
InsideExclusive
(
p
,
sampleBounds
))
return
{};
return
values
[(
p
.
z
*
ny
+
p
.
y
)
*
nx
+
p
.
x
];
}
template
<
typename
T
>
inline
T
SampledGrid
<
T
>::
MaximumValue
(
const
Bounds3f
&
bounds
)
const
{
Point3f
ps
[
2
]
=
{
Point3f
(
bounds
.
pMin
.
x
*
nx
-
.5
f
,
bounds
.
pMin
.
y
*
ny
-
.5
f
,
bounds
.
pMin
.
z
*
nz
-
.5
f
),
Point3f
(
bounds
.
pMax
.
x
*
nx
-
.5
f
,
bounds
.
pMax
.
y
*
ny
-
.5
f
,
bounds
.
pMax
.
z
*
nz
-
.5
f
)};
Point3i
pi
[
2
]
=
{
Max
(
Point3i
(
Floor
(
ps
[
0
])),
Point3i
(
0
,
0
,
0
)),
Min
(
Point3i
(
Floor
(
ps
[
1
]))
+
Vector3i
(
1
,
1
,
1
),
Point3i
(
nx
-
1
,
ny
-
1
,
nz
-
1
))};
T
maxValue
=
Lookup
(
Point3i
(
pi
[
0
]));
for
(
int
z
=
pi
[
0
].
z
;
z
<=
pi
[
1
].
z
;
++
z
)
for
(
int
y
=
pi
[
0
].
y
;
y
<=
pi
[
1
].
y
;
++
y
)
for
(
int
x
=
pi
[
0
].
x
;
x
<=
pi
[
1
].
x
;
++
x
)
{
using
std
::
max
;
maxValue
=
max
(
maxValue
,
Lookup
(
Point3i
(
x
,
y
,
z
)));
}
return
maxValue
;
}
}
// namespace pbrt
#endif // PBRT_UTIL_CONTAINERS_H
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录