Custom move element tool is not fast as the built-in Microstation "Move extended" when hundreds of elements are manipulated[V8i MDL]

Hello! It´s me again, with a question.

I´m currently working with a Microstation V8i SS4 version, where I needed to add my own functionality to the move tool, so I´ve decided that I will implement myself it with MDL API, as VBA didn´t offer me the things I wanted (and the tool didn´t have that "native microstation tool" feeling). It was also a great opportunity to learn new things.

Functionality is working properly. Everything was great until I have decided to add support of selection set for my tool. Now I was facing a problem with performance, where for example I move around like 500+ elements (of all kinds) and I can see that the FPS is dropped (so the movement is not that smooth). I´ve tried to do the same thing with the "move extended" keyin (I simply launched it from my C++ code) and the performance was much better, smoother, as the number of elements selected didn´t affect it at all.

Now to the implementation (as the code is quite complex I won´t share it all):

Depending on whether user uses selection set or no, I start Modify command
    if (mdlSelect_numSelected() > 0)
    {
        mdlState_startModifyCommand(NULL, acceptFunc, updateFunc, NULL, NULL, 0, 0, TRUE, 2);       
    }
    else
    {
        mdlState_startModifyCommand(NULL, acceptFunc, updateFunc, NULL, NULL, 0, 0, FALSE, 0);
    }
    
Then I set some mdlLocate settings like enabling accusnap etc. (as I think it does not affect
the perfomance, I will skip that)

From the selected elements, I iterate through them, receive ElementRef and create transient elements (the copies that you see moving around with mouse)

    MSElementDescr* descr = nullptr;
    ElementRef descrRef = elementRef_getParent(ref);
    if (descrRef == NULL)
    {
        descrRef = ref;
    }

    mdlElmdscr_getByElemRef(&descr, descrRef, mdlModelRef_getActive(), 0, 0);
    TransDescrP createdTrans = mdlTransient_addElemDescr(NULL, descr, FALSE, 0x00ff, DRAW_MODE_TempDraw, FALSE, FALSE, FALSE);
    _transDescriptors.emplace_back(createdTrans);
    
Then in the dynamic update function, I move them according to the movements of my mouse

for(int i = 0; i < _transDescriptors.size(); i++)
    {
        MSElementDescr* descr;
        mdlTransient_returnElemDescr(&descr, _transDescriptors[i]);

        Transform transformMatrix;
        mdlTMatrix_getIdentity(&transformMatrix);
        mdlTMatrix_setTranslation(&transformMatrix, &mousePoint);
        mdlElmdscr_transform(descr, &transformMatrix);     
        
        _transDescriptors[i] = mdlTransient_replaceElemDescr(_transDescriptors[i], _copyDescriptors[i], FALSE, 0x00ff, DRAW_MODE_TempDraw, FALSE, TRUE, TRUE);
    }

Thats my main approach, but I also tried a different one, but with same results:

Instead of iterating through all elements, I added them to a temporary created cell (using mdlElmdscr_append).

Then i simply just translated this single element, however it didn´t improve the performance, or run smoother.

Do you guys have some ideas what could cause my problems? Is there some workaround to speed up described behavior? Thanks in advance.

Parents Reply Children
No Data