Skip to content

Commit

Permalink
[release] neednrrow
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Jul 28, 2022
1 parent 8cd9a8d commit a152c01
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
14 changes: 8 additions & 6 deletions projects/zenvdb/MeshToSDF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,19 @@ static int defPrimitiveToSDF = zeno::defNodeClass<PrimitiveToSDF>("PrimitiveToSD
struct SDFToFog : INode
{
virtual void apply() override {
auto sdf = get_input("SDF")->as<VDBFloatGrid>();
auto result = zeno::IObject::make<VDBFloatGrid>();
auto dx = sdf->m_grid->voxelSize()[0];
result->m_grid = sdf->m_grid->deepCopy();
openvdb::tools::sdfToFogVolume(*(result->m_grid));
set_output("oSDF", result);
auto sdf = get_input<VDBFloatGrid>("SDF");
if (!has_input("inplace") || !get_input2<bool>("inplace")) {
sdf = std::make_shared<VDBFloatGrid>(sdf->m_grid->deepCopy());
}
//auto dx = sdf->m_grid->voxelSize()[0];
openvdb::tools::sdfToFogVolume(*(sdf->m_grid));
set_output("oSDF", std::move(sdf));
}
};
static int defSDFToFog = zeno::defNodeClass<SDFToFog>("SDFToFog",
{ /* inputs: */ {
"SDF",
{"bool", "inplace", "0"},
}, /* outputs: */ {
"oSDF",
}, /* params: */ {
Expand Down
20 changes: 14 additions & 6 deletions projects/zenvdb/VDBPointScatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,43 @@
#include <zeno/types/DictObject.h>
#include <openvdb/points/PointScatter.h>
#include <zeno/VDBGrid.h>
#include <zeno/core/Graph.h>
#include <random>

namespace zeno {
namespace {

struct VDBPointScatter : INode{
virtual void apply() override {
auto sdf = get_input<VDBFloatGrid>("SDF");
auto grid = get_input<VDBFloatGrid>("grid");
int count = get_input2<int>("count");
float spread = get_input2<float>("spread");
int seed = get_input2<int>("seed");
auto uniform = get_input2<std::string>("type") != "NonUniform";
auto uniform = get_input2<std::string>("method") != "NonUniform";
auto issdf = get_input2<std::string>("gridtype") == "SDF";
if (issdf) {
grid = std::static_pointer_cast<VDBFloatGrid>(
getThisGraph()->callTempNode("SDFToFog", {{"SDF", grid},
{"inplace", std::make_shared<NumericObject>((int)0)}}).at("oSDF"));
}
if (seed == -1) seed = std::random_device{}();

auto points = std::make_shared<VDBPointsGrid>(uniform ?
openvdb::points::uniformPointScatter(*sdf->m_grid, openvdb::Index64(count), seed, spread) :
openvdb::points::nonUniformPointScatter(*sdf->m_grid, openvdb::Index64(count), seed, spread)
openvdb::points::uniformPointScatter(*grid->m_grid, openvdb::Index64(count), seed, spread) :
openvdb::points::nonUniformPointScatter(*grid->m_grid, openvdb::Index64(count), seed, spread)
);

set_output("points", std::move(points));
}
};
ZENO_DEFNODE(VDBPointScatter)(
{ /* inputs: */ {
"SDF",
"grid",
{"int", "count", "100"},
{"float", "spread", "1"},
{"int", "seed", "-1"},
{"enum Uniform NonUniform", "type", "Uniform"},
{"enum Fog SDF", "gridtype", "Fog"},
{"enum Uniform NonUniform", "method", "Uniform"},
}, /* outputs: */ {
"points",
}, /* params: */ {
Expand Down
8 changes: 6 additions & 2 deletions projects/zenvdb/include/zeno/VDBGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ struct VDBGridWrapper : zeno::IObjectClone<VDBGridWrapper<GridT>, VDBGrid> {
VDBGridWrapper(typename GridT::Ptr &&ptr) { m_grid = std::move(ptr); }

VDBGridWrapper(VDBGridWrapper const &other) {
m_grid = other.m_grid->deepCopy();
if (other.m_grid)
m_grid = other.m_grid->deepCopy();
}

VDBGridWrapper &operator=(VDBGridWrapper const &other) {
m_grid = other.m_grid->deepCopy();
if (other.m_grid)
m_grid = other.m_grid->deepCopy();
else
m_grid = nullptr;
return *this;
}

Expand Down
3 changes: 2 additions & 1 deletion ui/zenoedit/zenoapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

ZenoApplication::ZenoApplication(int &argc, char **argv)
: QApplication(argc, argv)
, m_pGraphs(new GraphsManagment(this))
, m_pGraphs(new GraphsManagment())
, m_bIOProcessing(false)
, m_errSteam(std::clog)
, m_server(nullptr)
Expand All @@ -33,6 +33,7 @@ ZenoApplication::ZenoApplication(int &argc, char **argv)

ZenoApplication::~ZenoApplication()
{
delete m_pGraphs;
}

QString ZenoApplication::readQss(const QString& qssPath)
Expand Down

0 comments on commit a152c01

Please sign in to comment.