Found 7 posts.
Search results Show results as topic list.
Technical Discussion » Copying points from one GU_Detail to another
- riotnrrd
- 7 posts
- Offline
To answer my own question, I can track the current index of the point I'm adding, and then use the indexToOffset() function to get the offset I need.
Technical Discussion » Copying points from one GU_Detail to another
- riotnrrd
- 7 posts
- Offline
I'm writing a SOP in C++. I have an input GU_Detail and I wish to copy some its points, including all attributes, to my output GU_Detail. However, for each point I decide copy over, I need its GA_Offset, so I can add my own attributes or change the ones that exist. How can I do this?
Right now, I'm doing something like:
// Copy the points and their attributes
for (GA_Iterator it(gdp_input->getPointRange()); !it.atEnd(); ++it)
{
GA_PointGroup* grp = gdp_input->newPointGroup(“tmpgrp”, false);
grp->addOffset(*it);
GA_Range range(*grp);
gdp->mergePoints(*gdp_input, range);
// need the offset here for further operations
}
While this successfully copies points and their attributes from “gdp_input” to “gdp”, it doesn't give me an offset.
I could then do something like:
// need the offset here for further operations
GA_IndexMap tmpMap(*gdp, GA_ATTRIB_POINT);
offset = tmpMap.lastOffset();
}
But there is no indication in the documentation (if it could be called that) of ‘lastOffset’ what exactly ‘last’ means. Is it the most-recently added point? The largest offset? The offset of the largest index? None of these?
Right now, I'm doing something like:
// Copy the points and their attributes
for (GA_Iterator it(gdp_input->getPointRange()); !it.atEnd(); ++it)
{
GA_PointGroup* grp = gdp_input->newPointGroup(“tmpgrp”, false);
grp->addOffset(*it);
GA_Range range(*grp);
gdp->mergePoints(*gdp_input, range);
// need the offset here for further operations
}
While this successfully copies points and their attributes from “gdp_input” to “gdp”, it doesn't give me an offset.
I could then do something like:
// need the offset here for further operations
GA_IndexMap tmpMap(*gdp, GA_ATTRIB_POINT);
offset = tmpMap.lastOffset();
}
But there is no indication in the documentation (if it could be called that) of ‘lastOffset’ what exactly ‘last’ means. Is it the most-recently added point? The largest offset? The offset of the largest index? None of these?
Technical Discussion » Determine if an input has changed since the last cook
- riotnrrd
- 7 posts
- Offline
Okay. So this does not work:
GU_Topology topo;
int changed = 0;
duplicateChangedSource(0, context, topo, &changed, gdp_input0);
if (changed == 1)
inputChanged = true;
(“changed” is always equal to 1).
But this appears to (kind of; there are some false positives):
int changed = 0;
duplicateChangedSource(0, context, &changed);
if (changed == 1)
{
inputChanged = true;
gdp_input0->copy(*gdp);
gdp->clearAndDestroy();
}
GU_Topology topo;
int changed = 0;
duplicateChangedSource(0, context, topo, &changed, gdp_input0);
if (changed == 1)
inputChanged = true;
(“changed” is always equal to 1).
But this appears to (kind of; there are some false positives):
int changed = 0;
duplicateChangedSource(0, context, &changed);
if (changed == 1)
{
inputChanged = true;
gdp_input0->copy(*gdp);
gdp->clearAndDestroy();
}
Technical Discussion » Determine if an input has changed since the last cook
- riotnrrd
- 7 posts
- Offline
I have a SOP node with two inputs. I wish to regenerate some data if and only if the data on input 0 has changed since my last cook. (If input 1 has changed, I do something else.)
Is there a mechanism in the HDK to detect this? I tried using “checkChangedSourceFlags” but even with my upsteam inputs locked, the ‘changed’ flag is always 1.
I am writing this SOP in C++, and using Houdini 12
Is there a mechanism in the HDK to detect this? I tried using “checkChangedSourceFlags” but even with my upsteam inputs locked, the ‘changed’ flag is always 1.
I am writing this SOP in C++, and using Houdini 12
Edited by - Aug. 29, 2012 13:21:07
Technical Discussion » Writing and reading blind data
- riotnrrd
- 7 posts
- Offline
Back at work now in front of Houdini, I can verify that is it NOT the merge node which is losing my data. Or, at least I can verify that connecting the source OP to the target OP gives the same (broken) results.. Has anyone else out there ever tried to pass blind data using the technique I outlined above?
Technical Discussion » Writing and reading blind data
- riotnrrd
- 7 posts
- Offline
I realized on my way home that I had a “merge” node between my custom SOP which generated the blind data, and the custom SOP that consumes it. Maybe the merge node isn't passing my blind data?
I can't test this right now but, if this theory is true, what might I doing wrong?
I can't test this right now but, if this theory is true, what might I doing wrong?
Technical Discussion » Writing and reading blind data
- riotnrrd
- 7 posts
- Offline
I need to pass some blind data (contained in a class) from one custom C++ SOP node to another. The documentation at http://www.sidefx.com/docs/hdk12.0/hdk_ga_porting.html#HDK_GA_Porting_Blind [sidefx.com] is useful, but I'm running into problems. I am using 12.0.661
I'm creating my data thusly:
GA_RWAttributeRef blind_attr = gdp->createAttribute(
GA_ATTRIB_POINT, GA_SCOPE_PRIVATE, ATTR_MY_BLIND_DATA,
NULL, NULL, “blinddata”);
if (!blind_attr.isValid())
{
addError(SOP_MESSAGE, “Failed to create blind Data.”);
return;
}
GA_Attribute* a = blind_attr.getAttribute();
const GA_AIFBlindData* aif;
if (aif = a->getAIFBlindData())
{
MyData default_value;
const void* vptr = reinterpret_cast<void*>(&default_value);
aif->setDataSize(a, sizeof(MyData), vptr);
}
else
{
addError(SOP_MESSAGE, “Failed to allocate blind data.”);
return;
}
//….
// Set blind data values
MyData& mydata = aif->getWriteValue<MyData>(a, offset);
mydata.foo = foo;
// etc.
This appears to work (no segfaults at any rate..)
Now, in a second SOP node I am attempting to read this data:
GA_ROAttributeRef blind_attr = gdp_input->findPointAttribute(
GA_SCOPE_PRIVATE, ATTR_MY_BLIND_DATA);
if (!blind_attr.isValid())
return false;
const GA_Attribute* blind_a = blind_attr.getAttribute();
const GA_AIFBlindData* blind_aif = blind_a->getAIFBlindData();
if (!blind_aif)
return false;
However the “blind_attr.isValid()” test always fails. What might I be doing wrong? How can I debug this effectively? Is there a way to tell that I have properly allocated and set data when writing it? Finally, I am assuming that Houdini takes care of deleting the allocated data. Is this correct?
I'm creating my data thusly:
GA_RWAttributeRef blind_attr = gdp->createAttribute(
GA_ATTRIB_POINT, GA_SCOPE_PRIVATE, ATTR_MY_BLIND_DATA,
NULL, NULL, “blinddata”);
if (!blind_attr.isValid())
{
addError(SOP_MESSAGE, “Failed to create blind Data.”);
return;
}
GA_Attribute* a = blind_attr.getAttribute();
const GA_AIFBlindData* aif;
if (aif = a->getAIFBlindData())
{
MyData default_value;
const void* vptr = reinterpret_cast<void*>(&default_value);
aif->setDataSize(a, sizeof(MyData), vptr);
}
else
{
addError(SOP_MESSAGE, “Failed to allocate blind data.”);
return;
}
//….
// Set blind data values
MyData& mydata = aif->getWriteValue<MyData>(a, offset);
mydata.foo = foo;
// etc.
This appears to work (no segfaults at any rate..)
Now, in a second SOP node I am attempting to read this data:
GA_ROAttributeRef blind_attr = gdp_input->findPointAttribute(
GA_SCOPE_PRIVATE, ATTR_MY_BLIND_DATA);
if (!blind_attr.isValid())
return false;
const GA_Attribute* blind_a = blind_attr.getAttribute();
const GA_AIFBlindData* blind_aif = blind_a->getAIFBlindData();
if (!blind_aif)
return false;
However the “blind_attr.isValid()” test always fails. What might I be doing wrong? How can I debug this effectively? Is there a way to tell that I have properly allocated and set data when writing it? Finally, I am assuming that Houdini takes care of deleting the allocated data. Is this correct?
Edited by - Aug. 4, 2012 13:11:38
-
- Quick Links