[Closed] SDK: BitArray::SetAll broken in Max 2014/2015 ???
So I’m trying to make my own version of the Relax modifier. Got it working in 2012, 2013, and 2016, but noticed some strange behavior in 2014 and 2015.
To try and figure out what I was doing wrong, I compiled the Relax modifier from the samples directory, but discovered that the same thing was happening! I tracked the source of the problem down to the BitArray::SetAll function. I added a line to the following code to output the stored value for whether each vertex should be treated as selected:
// mjm - begin - 4.8.99
// if (selLevel==MESH_VERTEX) rd->sel = mesh->vertSel;
if (selLevel==MESH_VERTEX)
rd->sel = mesh->vertSel;
else if (selLevel==MESH_OBJECT)
rd->sel.SetAll ();
for (int v = 0; v < mesh->getNumVerts(); v++) mprintf(_T(" rd->sel[%i]: %i
"), v, rd->sel[v]);
// mjm - end
The results should show true for all values of rd->sel, and in all versions of Max but 2014 and 2015, they do. But for the versions in question, it shows true for every vertex up to 95, and then mostly false with sporadic true values scattered through the rest!
rd->sel[93]: 1
rd->sel[94]: 1
rd->sel[95]: 1
rd->sel[96]: 0
rd->sel[97]: 0
rd->sel[98]: 1
rd->sel[99]: 0
rd->sel[100]: 1
rd->sel[101]: 0
rd->sel[102]: 0
rd->sel[103]: 1
rd->sel[104]: 0
rd->sel[105]: 0
rd->sel[106]: 0
rd->sel[107]: 0
rd->sel[108]: 0
rd->sel[109]: 0
rd->sel[110]: 0
rd->sel[111]: 0
rd->sel[112]: 0
rd->sel[113]: 0
I even tried removing the conditions and directly setting rd->sel.SetAll() immediately prior to the for loop, with no changes. I’m trying and failing to make sense of what I’m seeing. Can anyone shed some light on this?
You probably forgot the WIN64 preprocessor definition
Solution: http://forums.autodesk.com/t5/3ds-max-programming/a-bug-of-bitarray/m-p/5539331#M13220
may i ask you a question? what is rd? this is probably your plugin, and i don’t know how you realized bitarray inside.
try any BitArray:
BitArray bits;
bits.SetSize(100000);
bits.SetAll();
mprintf(_M("count:%i, number set:%i
"), bits.GetSize(), bits.NumberSet());
if it works search of anything wrong in your code
hd: yep, it turns out that is exactly what it was.
denis: actually the rd was directly from the sample file, where it is defined as
RelaxBySGModData *rd = (RelaxBySGModData *)mc.localData;
But it works now, and I’ll remember to include WIN64 in the preprocessor definitions for all 64-bit configurations from here on out!