[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60361] branches/soc-2013-cycles_volume/ intern/cycles/kernel/textures: VDB texture:
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed Sep 25 01:28:20 CEST 2013
Revision: 60361
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60361
Author: blendix
Date: 2013-09-24 23:28:19 +0000 (Tue, 24 Sep 2013)
Log Message:
-----------
VDB texture:
* Avoid slow file open every time valid_vdb_file is called (in every texture3D
call), do a quick filename extension check for now.
* Pass float coordinates to the GridSampler instead of rounding to integers.
Modified Paths:
--------------
branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_definitions.h
branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_lookup.h
branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_volume.cpp
Modified: branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_definitions.h
===================================================================
--- branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_definitions.h 2013-09-24 23:24:12 UTC (rev 60360)
+++ branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_definitions.h 2013-09-24 23:28:19 UTC (rev 60361)
@@ -23,8 +23,9 @@
#include <openvdb/tools/Interpolation.h>
//#include <OpenImageIO/ustring.h>
#include <OSL/oslconfig.h>
-#include <vector.h>
+#include "util_vector.h"
+
CCL_NAMESPACE_BEGIN
using OpenImageIO::ustring;
Modified: branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_lookup.h
===================================================================
--- branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_lookup.h 2013-09-24 23:24:12 UTC (rev 60360)
+++ branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_lookup.h 2013-09-24 23:28:19 UTC (rev 60361)
@@ -47,8 +47,8 @@
//getGrid
openvdb::GridBase::Ptr getGridPtr();
- void vdb_lookup_single_point(int i, int j, int k, float *result);
- void vdb_lookup_multiple_points(int i[], int j[], int k[], float *result);
+ void vdb_lookup_single_point(float x, float y, float z, float *result);
+ void vdb_lookup_multiple_points(float x[], float y[], float z[], float *result);
private:
@@ -56,16 +56,16 @@
VDB_GridType m_type;
template <typename GridType>
- void vdb_lookup_nearest_neighbor(float i, float j, float k, float *result);
+ void vdb_lookup_nearest_neighbor(float x, float y, float z, float *result);
template <typename GridType>
- void vdb_lookup_trilinear(float i, float j, float k, float *result);
+ void vdb_lookup_trilinear(float x, float y, float z, float *result);
template <typename GridType>
- typename GridType::ValueType vdb_lookup_single_point(int i, int j, int k);
+ typename GridType::ValueType vdb_lookup_single_point(float x, float y, float z);
template <typename GridType>
- typename GridType::ValueType* vdb_lookup_multiple_points(int i[], int j[], int k[], int num);
+ typename GridType::ValueType* vdb_lookup_multiple_points(float x[], float y[], float z[], int num);
template <typename GridType>
typename GridType::TreeType::template ValueAccessor<typename GridType::TreeType> get_value_accessor();
@@ -108,39 +108,39 @@
array[i] = vec[i];
}
-void VDBAccessor::vdb_lookup_single_point(int i, int j, int k, float *result)
+void VDBAccessor::vdb_lookup_single_point(float x, float y, float z, float *result)
{
switch (m_type) {
case VDB_GRID_BOOL:
- *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::BoolGrid>(i, j, k));
+ *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::BoolGrid>(x, y, z));
break;
case VDB_GRID_FLOAT:
- *result = VDBAccessor::vdb_lookup_single_point<openvdb::FloatGrid>(i, j, k);
+ *result = VDBAccessor::vdb_lookup_single_point<openvdb::FloatGrid>(x, y, z);
break;
case VDB_GRID_DOUBLE:
- *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::DoubleGrid>(i, j, k));
+ *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::DoubleGrid>(x, y, z));
break;
case VDB_GRID_INT32:
- *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::Int32Grid>(i, j, k));
+ *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::Int32Grid>(x, y, z));
break;
case VDB_GRID_INT64:
- *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::Int64Grid>(i, j, k));
+ *result = static_cast<float>(VDBAccessor::vdb_lookup_single_point<openvdb::Int64Grid>(x, y, z));
break;
case VDB_GRID_VEC3I:
{
- openvdb::Vec3i result3i = VDBAccessor::vdb_lookup_single_point<openvdb::Vec3IGrid>(i, j, k);
+ openvdb::Vec3i result3i = VDBAccessor::vdb_lookup_single_point<openvdb::Vec3IGrid>(x, y, z);
copyVectorToFloatArray(result3i, result, 3);
break;
}
case VDB_GRID_VEC3F:
{
- openvdb::Vec3f result3f = VDBAccessor::vdb_lookup_single_point<openvdb::Vec3fGrid>(i, j, k);
+ openvdb::Vec3f result3f = VDBAccessor::vdb_lookup_single_point<openvdb::Vec3fGrid>(x, y, z);
copyVectorToFloatArray(result3f, result, 3);
break;
}
case VDB_GRID_VEC3D:
{
- openvdb::Vec3d result3d = VDBAccessor::vdb_lookup_single_point<openvdb::Vec3DGrid>(i, j, k);
+ openvdb::Vec3d result3d = VDBAccessor::vdb_lookup_single_point<openvdb::Vec3DGrid>(x, y, z);
copyVectorToFloatArray(result3d, result, 3);
break;
}
@@ -150,19 +150,19 @@
}
template <typename GridType>
-typename GridType::ValueType VDBAccessor::vdb_lookup_single_point(int i, int j, int k)
+typename GridType::ValueType VDBAccessor::vdb_lookup_single_point(float x, float y, float z)
{
typename GridType::Ptr grid = openvdb::gridPtrCast<GridType>(getGridPtr());
typename GridType::Accessor acc = grid->getAccessor();
openvdb::tools::GridSampler<openvdb::tree::ValueAccessor<typename GridType::TreeType>, openvdb::tools::PointSampler> sampler(acc);
- openvdb::Vec3d p(i, j, k);
-
+ openvdb::Vec3d p(x, y, z);
+
return sampler.wsSample(p);
}
template <typename GridType>
-typename GridType::ValueType* VDBAccessor::vdb_lookup_multiple_points(int i[], int j[], int k[], int num)
+typename GridType::ValueType* VDBAccessor::vdb_lookup_multiple_points(float x[], float y[], float z[], int num)
{
GridType typedGrid = *(openvdb::gridPtrCast<GridType>(m_grid));
typename GridType::ValueType result;
@@ -173,7 +173,7 @@
for (int pos = 0; pos < num; pos++) {
- xyz = openvdb::math::Coord(i[pos], j[pos], k[pos]);
+ xyz = openvdb::math::Coord(x[pos], y[pos], z[pos]);
result[pos] = accessor.getValue(xyz);
}
Modified: branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_volume.cpp
===================================================================
--- branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_volume.cpp 2013-09-24 23:24:12 UTC (rev 60360)
+++ branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/vdb_volume.cpp 2013-09-24 23:28:19 UTC (rev 60361)
@@ -20,7 +20,7 @@
#include "vdb_util.h"
#include "vdb_lookup.h"
#include "vdb_volume.h"
-#include <ctime>
+#include <string.h>
CCL_NAMESPACE_BEGIN
@@ -33,7 +33,15 @@
bool VDBTextureSystem::valid_vdb_file(ustring filename)
{
- return OpenVDBUtil::is_vdb_volume_file(filename);
+ //This opens the file, much too slow!
+ //return OpenVDBUtil::is_vdb_volume_file(filename);
+
+ size_t length = filename.length();
+
+ if(length < 4)
+ return false;
+
+ return strcmp(filename.data() + length - 4, ".vdb") == 0;
}
bool VDBTextureSystem::perform_lookup(ustring filename, OIIO::TextureSystem::Perthread *thread_info,
@@ -90,3 +98,4 @@
}
CCL_NAMESPACE_END
+
More information about the Bf-blender-cvs
mailing list