Problem with GetModelingAxis() [CLOSED]
-
On 06/07/2015 at 03:31, xxxxxxxx wrote:
Hi,
Well, I have no code relevant to this bug?, but if you mean code to test the bug? out, here you go:
case DLG_BUTTON_SET: { BaseDocument *doc = GetActiveDocument(); doc->StartUndo(); Float posX; this->GetFloat(DLG_EDITNUMBER_X, posX); Float posY; this->GetFloat(DLG_EDITNUMBER_Y, posY); Float posZ; this->GetFloat(DLG_EDITNUMBER_Z, posZ); Vector newPosition = Vector(posX, posY, posZ); Int32 setAxis; this->GetInt32(DLG_RADIOGROUP_AXIS_SET, setAxis); Bool setX; this->GetBool(DLG_CHECKBOX_SET_X, setX); Bool setY; this->GetBool(DLG_CHECKBOX_SET_Y, setY); Bool setZ; this->GetBool(DLG_CHECKBOX_SET_Z, setZ); Int32 modelModeSet = doc->GetMode(); .... else if (modelModeSet == Mpoints) { AutoAlloc<AtomArray> selection; if (!selection) return false; if (doc) { doc->GetActiveObjects(*selection, GETACTIVEOBJECTFLAGS_0); op = doc->GetActiveObject(); } if (selection->GetCount() > 1) { Vector globalModelingAxis = doc->GetHelperAxis()->GetMg().off; for (Int32 x = 0; x < selection->GetCount(); x++) { Matrix objectAxis = static_cast<BaseObject*>(selection->GetIndex(x))->GetMg(); PointObject *opPoint = static_cast<PointObject*>(selection->GetIndex(x)); if (!opPoint) return false; Matrix modelingAxis = opPoint->GetModelingAxis(doc); doc->AddUndo(UNDOTYPE_CHANGE, opPoint); Vector *points = opPoint->GetPointW(); if (!points) return false; BaseSelect *bs = opPoint->GetPointS(); if (!bs) return false; for (Int32 y = 0; y < opPoint->GetPointCount(); y++) { if (bs->IsSelected(y)) { if (setAxis == DLG_RADIOGROUP_AXIS_SET_GLOBAL) { Vector projection = newPosition; if (setX == true) projection.x = newPosition.x - globalModelingAxis.x; if (setY == true) projection.y = newPosition.y - globalModelingAxis.y; if (setZ == true) projection.z = newPosition.z - globalModelingAxis.z; points[y] = points[y] + projection; } else if (setAxis == DLG_RADIOGROUP_AXIS_SET_LOCAL) { Vector projection = newPosition; if (setX == true) projection.x = newPosition.x - modelingAxis.off.x + objectAxis.off.x; if (setY == true) projection.y = newPosition.y - modelingAxis.off.y + objectAxis.off.y; if (setZ == true) projection.z = newPosition.z - modelingAxis.off.z + objectAxis.off.z; points[y] = points[y] + projection; } } } opPoint->Message(MSG_UPDATE); } } else if (selection->GetCount() == 1) { Matrix modelingAxis = op->GetModelingAxis(doc); Matrix objectAxis = op->GetMg(); PointObject *opPoint = (PointObject* )op; if (!opPoint) return false; doc->AddUndo(UNDOTYPE_CHANGE, opPoint); Int32 pointCount = opPoint->GetPointCount(); Vector *points = opPoint->GetPointW(); BaseSelect *bs = opPoint->GetPointS(); Int32 i; for (i = 0; i < pointCount; i++) { if (bs->IsSelected(i)) { if (setAxis == DLG_RADIOGROUP_AXIS_SET_GLOBAL) { Vector projection = newPosition; if (setX == true) projection.x = newPosition.x - modelingAxis.off.x; if (setY == true) projection.y = newPosition.y - modelingAxis.off.y; if (setZ == true) projection.z = newPosition.z - modelingAxis.off.z; points[i] = points[i] + projection; } else if (setAxis == DLG_RADIOGROUP_AXIS_SET_LOCAL) { Vector projection = newPosition; if (setX == true) projection.x = newPosition.x - modelingAxis.off.x + objectAxis.off.x; if (setY == true) projection.y = newPosition.y - modelingAxis.off.y + objectAxis.off.y; if (setZ == true) projection.z = newPosition.z - modelingAxis.off.z + objectAxis.off.z; points[i] = points[i] + projection; } } op->Message(MSG_UPDATE); } } else { MessageDialog(String("There is no object selected.")); } }
And the relevant layout:
GroupBegin(DLG_EDITNUMBER_GROUP, BFH_LEFT, 0, 3, "", false); AddEditNumber(DLG_EDITNUMBER_X, BFH_LEFT, 160); AddEditNumber(DLG_EDITNUMBER_Y, BFH_LEFT, 160); AddEditNumber(DLG_EDITNUMBER_Z, BFH_LEFT, 160); GroupEnd(); AddSeparatorV(20); GroupBegin(DLG_CHECKBOX_GROUP_SET, BFH_LEFT, 0, 3, "", false); AddCheckbox(DLG_CHECKBOX_SET_X, BFH_LEFT | BFV_SCALEFIT, 0, 0, "X"); AddCheckbox(DLG_CHECKBOX_SET_Y, BFH_LEFT | BFV_SCALEFIT, 0, 0, "Y"); AddCheckbox(DLG_CHECKBOX_SET_Z, BFH_LEFT | BFV_SCALEFIT, 0, 0, "Z"); GroupEnd(); AddSeparatorV(20); AddComboBox(DLG_RADIOGROUP_AXIS_SET, BFH_CENTER); AddChild(DLG_RADIOGROUP_AXIS_SET, DLG_RADIOGROUP_AXIS_SET_GLOBAL, "Global"); AddChild(DLG_RADIOGROUP_AXIS_SET, DLG_RADIOGROUP_AXIS_SET_LOCAL, "Local"); AddSeparatorV(20); AddButton(DLG_BUTTON_SET, BFH_LEFT, 0, 0, "SET"); GroupEnd();
I hope this is enough information, if not, just ask more.
Also I think this problem has nothing to do with my code, so testing it with simpler code may be easier.Thanks in advance for your help and time!
Greetings,
Casimir Smets -
On 06/07/2015 at 04:09, xxxxxxxx wrote:
Could it be, that the objects you are missing are always child objects?
Then you need to use the flag GETACTIVEOBJECTFLAGS_CHILDREN on GetActiveObjects(). -
On 06/07/2015 at 05:03, xxxxxxxx wrote:
Hi,
No, they are not children.
Greetings,
Casimir Smets -
On 06/07/2015 at 07:29, xxxxxxxx wrote:
I can't reproduce any problems here.
My simple test code used on a button:BaseDocument* doc = GetActiveDocument(); if (!doc) return false; AutoAlloc<AtomArray> selection; if (!selection) return false; doc->GetActiveObjects(*selection, GETACTIVEOBJECTFLAGS_0); for (Int32 x = 0; x < selection->GetCount(); x++) { GePrint(static_cast<BaseObject*>(selection->GetIndex(x))->GetName()); }
It print's just fine every selected object. Regardless, if I do a select all, use mouse drag selection or simply select a few with Shift-/Ctrl-Click. So I doubt this is a bug in Cinema.
Makes it also a bit difficult to help you.
Did you use a debugger to step through the code, in cases it doesn't work? -
On 06/07/2015 at 07:54, xxxxxxxx wrote:
Hi,
Well, that problem seems to only occur when I'm in point, edge or polygon mode.
That's probably why you couldn't reproduce it.And the problem is, my code ALWAYS works, it just sometimes doesn't work correctly (update the position to the wrong way). So debugging wouldn't help me, I guess.
Pff, this is really weird.
Should I make a video about how it behaves in C4D?
Thanks in advance for your help and time!
Cheers,
Casimir Smets -
On 06/07/2015 at 08:11, xxxxxxxx wrote:
Honestly, with "my code ALWAYS works, it just sometimes doesn't work correctly" you made my day
In my opinion, debugging always helps. Even if a program is producing results as expected, a debugger can generate great insights.
I tried it again, switching between point, edge and polygon modes. It didn't change, I still can't reproduce any irregularities with selecting objects. The code posted above still prints all selected objects.
I'm not sure, if a video will help. If you have the feeling, I did not understand the issue correctly, maybe a video can get us on the same page. On the other hand, the time might be better spent debugging your plugin. One strategy could be to consecutively deactivate more parts of your code, until either you found a part being responsible or you end up with a piece of code like mine above and you still see the issue. In the later case, we would probably need to file a bug report...
-
On 06/07/2015 at 10:18, xxxxxxxx wrote:
Hi Andreas,
Originally posted by xxxxxxxx
Honestly, with "my code ALWAYS works, it just sometimes doesn't work correctly" you made my day
Well, I'm glad I did
And it gives no problem with printing the objects.
The problem is when setting points, edges or polygons locally from a multi-objectselection.Maybe it's best if you try it with my code after all...
And I will debug my plugin straight away, and check if it helps something.
Greetings,
Casimir Smets -
On 06/07/2015 at 11:14, xxxxxxxx wrote:
Hi,
After debugging I found the line where the problem occurs, but I totally don't understand it!
Matrix modelingAxis = opPoint->GetModelingAxis(doc);
I have tested this with 2 cubes with point-mode on.
I first tested the select all method, and after that the shift-select method.In my first test, for my second cube, modelingAxis was just (0, 0, 0).
In my second test, for my second cube, modelingAxis was the proper value (84.250, 202.844, -32.124).
This happened with exactly the same code, so I am quite sure shift-select differs from select all. I definately can't see another reason right now.
Yeah, it's a thing!Is this enough information to file a bug report, or do you guys also need to do some testing?
If needed, I could provide my whole project to MAXON.
With kind regards,
Casimir Smets -
On 09/07/2015 at 09:00, xxxxxxxx wrote:
Hi Casimir,
unfortunately I still can't reproduce your issue.
I added code to print the offset of the modelling axis to my above code. No matter what method of selection (Ctrl-a, drag selection, shift or ctrl click) I tried and in which editing mode (points, edges, polys, object) I'm in, I always get all selected objects with correct modelling axis. -
On 09/07/2015 at 09:41, xxxxxxxx wrote:
Hi Andreas,
Currently I'm working with other code that doesn't give that problem, due to not using the modeling axis anymore, but I'll change my code back for a moment, to make the movie which shows the problem, and change my code back. Because I still think this is sort of a bug.
-
On 26/08/2015 at 09:24, xxxxxxxx wrote:
After quite some research, I think, there is an issue with GetModelingAxis(). I filed a bug report for this.
I mark this thread as closed, but will post an update, when it is fixed.Renamed thread from "Does select all differ from shift selecting??" to "Does select all differ from shift selecting??"
-
On 26/08/2015 at 09:46, xxxxxxxx wrote:
Hi Andreas,
Thanks for your answer!
I have to add that I had some problems recently with the protection tag, and also with the object-node with a rotation port combined with the universal node.
I think this could have something to do with the axises.Maybe those are related to each other?
The support team is currently busy with that, so if you want information about that, you can get it there. Or you could ask me to send the information via Mail, whatever you prefer.
It's just a thought here, I can be completely wrong about this one.
-
On 27/08/2015 at 11:16, xxxxxxxx wrote:
Hi Casimir,
it's pretty hard to tell, if there may be something related. Instead of getting several teams in parallel to work, I'd like to wait until you get response from support. And then it's probably a good thing to open a new thread, if any problem remains.