Hello;
we recently established here that the message MSG_TRANSLATE_POINTS
is no longer seriously in use.
I now tried to replace it by MSG_POLYGONS_CHANGED
and MSG_POINTS_CHANGED
, which both send a VariableChanged
struct as data. My attempt looks like follows:
if (type == MSG_POINTS_CHANGED)
{ // ONLY sent in case of added or removed points, not when points get moved
// This seems to trigger after a load/reload as well...?
GePrint("MSG_POINTS_CHANGED"_s);
VariableChanged* vc = (VariableChanged*)data;
GePrint("Old->New Count: " + String::IntToString(vc->old_cnt) + " -> " + String::IntToString(vc->new_cnt));
// vc->vc_flags = VC_SAFETY | VC_DONTCOPYDATA | VC_DONTCLEARDATA
if (vc->map == nullptr)
{
GePrint("No map"_s);
} else {
// old_cnt determines the size of the mapping array
// Entry i contains the new index for element i
// This should allow us to remap all existing entries
// All entries beyond old_cnt must be new
// NOTOK is possible (removed elements?)
for (Int32 i = 0; i < vc->old_cnt; i++)
{
if (vc->map[i] == NOTOK)
{
GePrint("Element dumped: " + String::IntToString(i));
} else {
GePrint("Element remapped: " + String::IntToString(i) + " to " + String::IntToString(vc->map[i]));
}
}
}
}
This code resides within the Message
method within a tag that is used on a Point or Polygon object. And it works insofar as I get the message. And the old_cnt
and new_cnt
values are correct.
What's missing is the map. I get No map
all the time, indicating that vc->map
is a nullptr
. That is the case for points and polygons alike, so I don't replicate the other code branch here, and it happens with any tool I tried (Delete, Add Point, Knife, Melt, Collapse, Dissolve, Subdivide, after that I lost interest in testing).
Without a map these messages are completely useless, as we can never find out which point or polygon has been deleted, or how the indices are moved. However, the documentation for VariableChanged
tells us, This is used to keep for example point selections and vertex maps valid.
Is that message deprecated too? How are point selections really kept up to date internally?