Author Topic: There are many ways to go to Rome.  (Read 53371 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: There are many ways to go to Rome.
« Reply #225 on: May 03, 2019, 06:37:20 pm »
Thanks for the update!

But no, still no branching on the stack. Let me explain it one more time.

When the bullet has traveled several locations and is brought back by Undo to some previous intermediate location, all the subsequent locations should be marked for deletion but not yet deleted. If then the bullet is propagated to the next known (already visited) location by Redo, that location should be unmarked for deletion (i.e. re-validated). But all the subsequent known locations should still stay marked for deletion. If all the subsequent already-visited locations are re-visited one by one in a similar manner using the Redo button, they all get re-validated one by one, finally re-validating the entire stack to its full depth. The stack stays as if you didn't press Undo then Redo at all.

OTOH if at some previous location Redo pressing stops and the bullet is instead moved to a completely new location by mouse or arrow key, then all the earlier locations that are still marked for deletion up to the very end of the UR array get completely discarded (cleared) from the stack (array memory) and thus forgotten forever. The new move that has just been made by mouse or arrow key goes on the UR stack and becomes the latest UR action and the last element in the UR array.

Is the branching mechanism clear for you this time or still not very?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: There are many ways to go to Rome.
« Reply #226 on: May 03, 2019, 06:53:07 pm »
There was an error in case TOR_UNDO, please use this one.
        case TOR_UNDO:
            UB = UBOUND(g_UR);
            if (gT.URidx < 0) { gT.URidx = UB - 1; }
            gT.URidx = max(gT.URidx - 1, -1);
            if (gT.URidx > -1) {
                g_UR[gT.URidx + 1].action = UR_UNDO; // Stack clear/release
                ZI_GetImageSizeFromControl(gT.hZoomCtrl, nW, nH);
                idx = g_UR[gT.URidx].idx;
                gtm_vertexBuffer[idx].texCoord[0] = g_UR[gT.URidx].rx;
                gtm_vertexBuffer[idx].texCoord[1] = g_UR[gT.URidx].ry;
                gT.wasX = g_UR[gT.URidx].wasX;
                gT.wasY = g_UR[gT.URidx].wasY;
                gT.wasIndex = g_UR[gT.URidx].index;;
                UpdateUVMAP(FALSE);
                if (!IsWindowEnabled(GetDlgItem(gT.hPanel, TOR_REDO))) { EnableRedo(TRUE); }
                if (gT.URidx == 0) { EnableUndo(FALSE); }
            }
            SetFocus(gT.hZoomCtrl);
            break;

I obviously did it wrong, because i am deleting the g_UR[K].action == UR_UNDO in WM_LBUTTONDOWN
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: There are many ways to go to Rome.
« Reply #227 on: May 03, 2019, 08:09:15 pm »
No, that doesn't work either. It doesn't follow my description in my previous Reply #225. It looks like nothing gets cleared from at least the Redo stack when a completely new route to move the bullet is taken from one of the intermediate locations that you have just reached by Undo or Redo. The stack still remembers all the locations visited since the hot spot was first selected for moving, and new locations along the new route are simply appended to the end of stack. :-\

Where is the code located that's responsible for clearing all the old array elements up to the very end of UR array which should become unreachable for both Undo and Redo the very moment when a new alternative route is taken to move the bullet at some intermediate location along the old route, please?

Where is the code located that re-validates, i.e. clears UR_UNDO/UR_REDO/whatever flags from, the location which has been reached by Undo and then left by subsequent Redo, please? UR_UNDO followed by UR_REDO should leave the location in a virgin state, as if it has never been revisited by walking the stack...
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: There are many ways to go to Rome.
« Reply #228 on: May 03, 2019, 09:01:43 pm »
I put the code at line 867, but it has been disabled until i could work back on it.

    case WM_LBUTTONDOWN:
        if (lstrlen(gT.zTex)) {
            DisplayMouseXY(hWnd, LOINT(lParam), HIINT(lParam)); // This is there that gT.x and gT.y are being set

            //// Stack clear/release
            //if (gT.URidx > -1) {
            //    UB = UBOUND(g_UR) -1;
            //    for (K = UB; K >= gT.URidx; K--) {
            //        if (g_UR[K].action == UR_UNDO) {
            //            g_UR.erase(g_UR.begin() + K);
            //        }
            //    }
            //}


            gT.UpDown = IS_DOWN;
            MouseMap();

            if (gT.wasIndex > -1) {
                if (ZI_GetObjectFocusID() != ID_DOT) {
                    ZI_SetObjectFocusID(ID_DOT);
                }
                if (ZI_IsLButtonDown()) {
                    DotMove = TRUE;
                }
            }
        }
        break;


see also line 1823 and 1842

        case TOR_UNDO:
            UB = UBOUND(g_UR);
            if (gT.URidx < 0) { gT.URidx = UB - 1; }
            gT.URidx = max(gT.URidx - 1, -1);
            if (gT.URidx > -1) {
                g_UR[gT.URidx + 1].action = UR_UNDO; // Stack clear/release
                ZI_GetImageSizeFromControl(gT.hZoomCtrl, nW, nH);
                idx = g_UR[gT.URidx].idx;
                gtm_vertexBuffer[idx].texCoord[0] = g_UR[gT.URidx].rx;
                gtm_vertexBuffer[idx].texCoord[1] = g_UR[gT.URidx].ry;
                gT.wasX = g_UR[gT.URidx].wasX;
                gT.wasY = g_UR[gT.URidx].wasY;
                gT.wasIndex = g_UR[gT.URidx].index;;
                UpdateUVMAP(TRUE);
                if (!IsWindowEnabled(GetDlgItem(gT.hPanel, TOR_REDO))) { EnableRedo(TRUE); }
                if (gT.URidx == 0) { EnableUndo(FALSE); }
            }
            SetFocus(gT.hZoomCtrl);
            break;
        case TOR_REDO:
            UB = UBOUND(g_UR);
            if (gT.URidx < UB - 1) {
                gT.URidx++;
                g_UR[gT.URidx].action = UR_REDO; // Stack clear/release
                ZI_GetImageSizeFromControl(gT.hZoomCtrl, nW, nH);
                idx = g_UR[gT.URidx].idx;
                gtm_vertexBuffer[idx].texCoord[0] = g_UR[gT.URidx].rx;
                gtm_vertexBuffer[idx].texCoord[1] = g_UR[gT.URidx].ry;
                gT.wasX = g_UR[gT.URidx].wasX;
                gT.wasY = g_UR[gT.URidx].wasY;
                gT.wasIndex = g_UR[gT.URidx].index;;
                UpdateUVMAP(TRUE);
                if (!IsWindowEnabled(GetDlgItem(gT.hPanel, TOR_UNDO))) { EnableUndo(TRUE); }
                if (gT.URidx == UB - 1) { EnableRedo(FALSE); }
            }
            SetFocus(gT.hZoomCtrl);
            break;

Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: There are many ways to go to Rome.
« Reply #229 on: May 04, 2019, 10:36:49 pm »
Patrice, I think I suddenly realized what's wrong with the UR stack. :o

There seems to be no matching stack branching/array clearing implemented for the arrow key moves yet. Therefore mixed mouse/key control seems broken as far as the UR stack is concerned...
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: There are many ways to go to Rome.
« Reply #230 on: May 17, 2019, 02:36:20 pm »
This is a small Tor fix

float rxCoord(IN long idx) {
    float ret = gtm_vertexBuffer[idx].texCoord[0];
    if ((ret < 0.0f) || (ret > 1.0f)) ret -= ((int)(ret / 1.0f)) * 1.0f;
    return ret;
}

float ryCoord(IN long idx) {
    float ret = gtm_vertexBuffer[idx].texCoord[1];
    if ((ret < 0.0f) || (ret > 1.0f)) ret -= ((int)(ret / 1.0f)) * 1.0f;
    return ret;
}

We should not floor the texcoord, if they are already within the correct 0-1 range.
Patrice
(Always working with the latest Windows version available...)