@@ -21,18 +21,24 @@ const std::string GaussianParticles::structureTypeName = "Gaussian Particles";
2121GaussianParticles::GaussianParticles (std::string name_, std::function<void ()>& drawCallback_,
2222 std::function<void ()>& extentsCallback_, std::function<void ()>& deletionCallback_)
2323 : Structure(name_, structureTypeName), drawCallback(drawCallback_), extentsCallback(extentsCallback_),
24- deletionCallback (deletionCallback_) {
24+ deletionCallback (deletionCallback_), subsampleFactor(uniquePrefix() + "subsampleFactor", 1) {
2525
26- // note : unlike other structures this does not call updateObjectSpaceBounds() here, to avoid a circular problem with
27- // the external class. we call it manually right after creation there.
26+ // Note : unlike other structures this does not call updateObjectSpaceBounds() here, to avoid a circular problem with
27+ // the external class. We call it manually right after creation there.
2828}
2929
3030GaussianParticles::~GaussianParticles () { deletionCallback (); }
3131
3232void GaussianParticles::buildCustomUI () {
3333 ensureImagebuffersAllocated (); // doing this here ensures we re-render after resizing
3434
35- ImGui::Text (" # particles: -1" );
35+ ImGui::Text (" %d Gaussians" , numParticles);
36+
37+ ImGui::PushItemWidth (100 );
38+ if (ImGui::InputInt (" render subsample" , &(subsampleFactor.get ()), 1 , 10 )) {
39+ setSubsampleFactor (subsampleFactor.get ());
40+ }
41+ ImGui::PopItemWidth ();
3642}
3743void GaussianParticles::buildCustomOptionsUI () {}
3844void GaussianParticles::buildPickUI (const PickResult& result) {}
@@ -45,7 +51,10 @@ void GaussianParticles::drawDelayed() {
4551
4652 ensureImagebuffersAllocated ();
4753
48- drawCallback ();
54+ if (!internal::renderPassIsRedraw) {
55+ // if doing multiple passes from the same view, no need to do this multiple times
56+ drawCallback ();
57+ }
4958
5059 if (!imageToScreenProgram) {
5160 prepareImageToScreenProgram ();
@@ -58,13 +67,23 @@ void GaussianParticles::drawPick() {}
5867void GaussianParticles::drawPickDelayed () {}
5968void GaussianParticles::updateObjectSpaceBounds () { extentsCallback (); }
6069
70+ void GaussianParticles::setSubsampleFactor (int32_t newVal) {
71+ newVal = std::max (1 , newVal);
72+ subsampleFactor = newVal;
73+ ensureImagebuffersAllocated ();
74+ }
75+
76+ int32_t GaussianParticles::getSubsampleFactor () { return subsampleFactor.get (); }
77+
6178void GaussianParticles::setExtents (glm::vec3 bbox_min, glm::vec3 bbox_max) {
6279 std::get<0 >(objectSpaceBoundingBox) = bbox_min;
6380 std::get<1 >(objectSpaceBoundingBox) = bbox_max;
6481 objectSpaceLengthScale = glm::length (bbox_max - bbox_min);
6582 requestRedraw ();
6683}
6784
85+ void GaussianParticles::setNumParticles (int32_t numParticles_) { numParticles = numParticles_; }
86+
6887std::string GaussianParticles::typeName () { return structureTypeName; }
6988void GaussianParticles::refresh () {}
7089
@@ -74,8 +93,8 @@ std::tuple<int32_t, int32_t> GaussianParticles::getRenderDims() {
7493}
7594
7695void GaussianParticles::ensureImagebuffersAllocated () {
77- int32_t newImageWidth = view::bufferWidth / subsampleFactor;
78- int32_t newImageHeight = view::bufferHeight / subsampleFactor;
96+ int32_t newImageWidth = view::bufferWidth / subsampleFactor. get () ;
97+ int32_t newImageHeight = view::bufferHeight / subsampleFactor. get () ;
7998
8099 if (newImageHeight == currImageHeight && newImageWidth == currImageWidth) {
81100 return ;
@@ -100,6 +119,12 @@ void GaussianParticles::ensureImagebuffersAllocated() {
100119 colors->data = std::vector<glm::vec4>(currImageWidth * currImageHeight, glm::vec4 (0 .0f ));
101120 colors->markHostBufferUpdated ();
102121
122+ if (imageToScreenProgram) {
123+ imageToScreenProgram->setTextureFromBuffer (" t_depth" , depths->getRenderTextureBuffer ().get ());
124+ imageToScreenProgram->setTextureFromBuffer (" t_color" , colors->getRenderTextureBuffer ().get ());
125+ }
126+
127+
103128 requestRedraw ();
104129}
105130
0 commit comments