Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
aiekick committed Mar 4, 2024
1 parent 19d6d75 commit c630210
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 3 additions & 2 deletions VdbWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class VdbTree : public ATree {
VdbTree(const std::string& vName) : ATree(vName) {}
virtual ~VdbTree() = default;

bool addVoxel(const uint32_t& vX, const uint32_t& vY, const uint32_t& vZ, void* vDatas, const size_t& vByteSize, const size_t& vCount) override {
bool addVoxel(const uint32_t& vX, const uint32_t& vY, const uint32_t& vZ, void* vDatas, const size_t& vByteSize, const size_t& vCount) override final {
if (vDatas != nullptr && vByteSize == sizeof(TType) && vCount == TCount) {
m_Volume.combine(dVec3((float)vX, (float)vY, (float)vZ));
const auto& bit_index_4 = getBitIndex4(vX, vY, vZ);
Expand Down Expand Up @@ -349,6 +349,7 @@ template <>
inline std::string VdbFloatGrid::getTypeName() {
return "Tree_float_5_4_3";
}

typedef VdbScalarGrid<double> VdbDoubleGrid;
template <>
inline std::string VdbDoubleGrid::getTypeName() {
Expand All @@ -368,7 +369,7 @@ class VdbVec3Grid : public VdbTree<TType, 3> {
VdbVec3Grid(const std::string& vName) : VdbTree<TType, 3>(vName) {}
virtual ~VdbVec3Grid() = default;
bool addVoxel(const uint32_t& vX, const uint32_t& vY, const uint32_t& vZ, const TType& v0, const TType& v1, const TType& v2) {
return VdbTree<TType, 3>::addVoxel(vX, vY, vZ, std::array<TType, 3>{v0, v1, v2});
return VdbTree<TType, 3>::addVoxel(vX, vY, vZ, {v0, v1, v2});
}
};

Expand Down
9 changes: 2 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
#include <chrono> // std::chrono
#include <cmath> // sin

#define USE_ANIMATED_WAVE
// #define JULIA_REVOLUTE
//#define USE_ANIMATED_WAVE
#define JULIA_REVOLUTE
// #define USE_Vdb_WRITER

#ifdef USE_ANIMATED_WAVE
int main() {
const int32_t SIZE = 150;
const double D_SIZE = (double)SIZE;
const int32_t OFFSET = SIZE;
const float Z_SCALE = 0.5f;
const int32_t FRAMES = 10;
const float len_ratio = 1.0f / (SIZE * SIZE);
Expand All @@ -27,7 +25,6 @@ int main() {
for (int32_t j = -SIZE; j < SIZE; ++j) {
float len = (i * i + j * j) * len_ratio;
int32_t pz = (int32_t)((std::sin(len * 10.0 + time) * 0.5 + 0.5) * (std::abs(50.0f - 25.0f * len)) * Z_SCALE);
int32_t cube_color = (int32_t)(len * 100.0) % 255 + 1;
auto px = i + SIZE;
auto py = j + SIZE;
floatLayerPtr->addVoxel(px, py, pz, 1.0f);
Expand Down Expand Up @@ -59,7 +56,6 @@ int main() {
std::array<int32_t, 3> offset = {};
bool first_offset = true;
vdb::VdbWriter vdb;
int32_t cube_color;
double time_step = 6.28318 / (double)FRAMES;
for (int32_t f = 0; f < FRAMES; ++f) {
vdb.setKeyFrame(f);
Expand Down Expand Up @@ -104,7 +100,6 @@ int main() {
offset[1] = k;
offset[2] = j;
}
cube_color = (int32_t)((std::sin(rev_x + rev_y) * 0.5 + 0.5) * 6.0) + 249;
densityLayerPtr->addVoxel(i + SIZE - offset[0], k + SIZE - offset[1], j + SIZE - offset[2], 1.0f);
sdfLayerPtr->addVoxel(i + SIZE - offset[0], k + SIZE - offset[1], j + SIZE - offset[2], df);
}
Expand Down

0 comments on commit c630210

Please sign in to comment.