From c10b96fe240649a320bd0cc5cd35a48675b42148 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 4 Dec 2016 19:59:25 +0100 Subject: [PATCH] Fixed: Support 3dsmax 2017 SDK --- .../plugin_max/nel_mesh_lib/export_script.cpp | 13 +++++++++++++ .../plugin_max/nel_patch_edit/np_epm_bevel.cpp | 9 ++++++++- .../nel_patch_edit/np_epm_extrude.cpp | 7 +++++++ .../nel_patch_edit/np_epm_remember.cpp | 17 +++++++++++++++++ .../plugin_max/nel_patch_lib/nel_patch_mesh.cpp | 15 ++++++++++++++- .../3d/plugin_max/nel_patch_paint/paint.cpp | 15 ++++++++++++--- .../plugin_max/nel_vertex_tree_paint/Paint.cpp | 12 ++++++++++++ .../nel_vertex_tree_paint/vertex_tree_paint.cpp | 7 +++++++ 8 files changed, 90 insertions(+), 5 deletions(-) diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp index 1e6304d18..cf99e2c0c 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_script.cpp @@ -38,9 +38,17 @@ bool CExportNel::scriptEvaluate (const char *script, void *out, TNelScriptValueT vl.parser = new Parser; vl.source = new StringStream (utf8ToTStr(script)); vl.source->log_to(NULL); + +#if MAX_VERSION_MAJOR < 19 save_current_frames(); +#endif + try { +#if MAX_VERSION_MAJOR >= 19 + ScopedSaveCurrentFrames currentFrames; +#endif + vl.source->flush_whitespace(); vl.code = vl.parser->compile_all(vl.source); vl.result = vl.code->eval(); @@ -66,11 +74,16 @@ bool CExportNel::scriptEvaluate (const char *script, void *out, TNelScriptValueT } catch (...) { +#if MAX_VERSION_MAJOR < 19 restore_current_frames(); +#endif result=FALSE; vl.source->close(); } + +#if MAX_VERSION_MAJOR < 19 pop_value_locals(); +#endif return (result!=FALSE); } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp index 0021d62f1..babcbea6c 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_bevel.cpp @@ -12,8 +12,12 @@ // ------------------------------------------------------------------------------------------------------------------------------------------------------ int EPM_BevelMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m) -{ +{ +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hwnd); +#else ViewExp *vpt = ip->GetViewport(hwnd); +#endif Point3 p0, p1; ISpinnerControl *spin; int ln, ln2; @@ -114,8 +118,11 @@ int EPM_BevelMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m break; } +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif + return TRUE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp index c4c502de9..0995edef4 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_extrude.cpp @@ -13,7 +13,11 @@ int EPM_ExtrudeMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 m) { +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hwnd); +#else ViewExp *vpt = ip->GetViewport(hwnd); +#endif Point3 p0, p1; ISpinnerControl *spin; BOOL ln; @@ -66,8 +70,11 @@ int EPM_ExtrudeMouseProc::proc(HWND hwnd, int msg, int point, int flags, IPoint2 break; } +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif + return TRUE; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp index 0fc1fabba..161187e35 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_remember.cpp @@ -35,8 +35,13 @@ int EditPatchMod::RememberPatchThere(HWND hWnd, IPoint2 m) ClearPatchDataFlag(mcList, EPD_BEENDONE); // See if we're over a patch +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hWnd); +#else ViewExp *vpt = ip->GetViewport(hWnd); +#endif GraphicsWindow *gw = vpt->getGW(); + HitRegion hr; MakeHitRegion(hr, HITTYPE_POINT, 1, 4, &m); gw->setHitRegion(&hr); @@ -110,8 +115,12 @@ int EditPatchMod::RememberPatchThere(HWND hWnd, IPoint2 m) finish: nodes.DisposeTemporary(); ClearPatchDataFlag(mcList, EPD_BEENDONE); + +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif + return result; } @@ -185,8 +194,13 @@ int EditPatchMod::RememberVertThere(HWND hWnd, IPoint2 m) ClearPatchDataFlag(mcList, EPD_BEENDONE); // See if we're over a vertex +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hWnd); +#else ViewExp *vpt = ip->GetViewport(hWnd); +#endif GraphicsWindow *gw = vpt->getGW(); + HitRegion hr; MakeHitRegion(hr, HITTYPE_POINT, 1, 4, &m); gw->setHitRegion(&hr); @@ -260,8 +274,11 @@ int EditPatchMod::RememberVertThere(HWND hWnd, IPoint2 m) finish: nodes.DisposeTemporary(); ClearPatchDataFlag(mcList, EPD_BEENDONE); + +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif return result; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp index 5dd6cd5a7..4aae66304 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_lib/nel_patch_mesh.cpp @@ -2261,9 +2261,18 @@ BOOL RPatchMesh::SubObjectHitTest (GraphicsWindow *gw, Material *ma, HitRegion * gw->setRndLimits(gw->getRndLimits() & ~GW_BACKCULL); bRet=mesh.SubObjectHitTest (gw, ma, hr, nFlags, list); +#if MAX_VERSION_MAJOR < 19 MeshSubHitRec *rec=list.First(); + while (rec) { +#else + MeshSubHitRec::Iterator it = list.begin(), iend = list.end(); + + while(it != iend) + { + MeshSubHitRec *rec = &*it; +#endif if (flags&SUBHIT_PATCH_SELONLY) { int otot=0; @@ -2284,7 +2293,11 @@ BOOL RPatchMesh::SubObjectHitTest (GraphicsWindow *gw, Material *ma, HitRegion * hitList.AddHit (rec->dist, &patch, nRemapedIndex, PATCH_HIT_TILE); // Next hit - rec=rec->Next(); +#if MAX_VERSION_MAJOR < 19 + rec = rec->Next(); +#else + ++it; +#endif } } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp index b5894e9a8..95d48caeb 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp @@ -4095,10 +4095,13 @@ DWORD WINAPI myThread (LPVOID vData) nlassert (pData->eproc->ip); // Viewport parameters - ViewExp* vp; Matrix3 affineTM; float minx,maxx,miny,maxy; - vp=pData->eproc->ip->GetActiveViewport(); +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vp = &pData->eproc->ip->GetActiveViewExp(); +#else + ViewExp *vp = pData->eproc->ip->GetActiveViewport(); +#endif vp->GetAffineTM(affineTM); if ( vp->IsPerspView() ) { @@ -4584,7 +4587,11 @@ int EPM_PaintMouseProc::proc( int flags, IPoint2 m) { - ViewExp *vpt = ip->GetViewport(hwnd); +#if MAX_VERSION_MAJOR >= 19 + ViewExp *vpt = &ip->GetViewExp(hwnd); +#else + ViewExp *vpt = ip->GetViewport(hwnd); +#endif int res = TRUE; static PatchMesh *shape1 = NULL; static int poly1, tile1, tile2, mesh1, mesh2, seg1; @@ -4613,8 +4620,10 @@ int EPM_PaintMouseProc::proc( break; } +#if MAX_VERSION_MAJOR < 19 if (vpt) ip->ReleaseViewport(vpt); +#endif return res; } diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp index 37b1b891b..241037218 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/Paint.cpp @@ -103,7 +103,11 @@ void PaintMouseProc::DoPainting(HWND hWnd, IPoint2 m) } VertexPaintData* d = (VertexPaintData*)mc->localData; +#if MAX_VERSION_MAJOR >= 19 + ViewExp* pView = &GetCOREInterface()->GetViewExp(hWnd); +#else ViewExp* pView = GetCOREInterface()->GetViewport(hWnd); +#endif Mesh* mesh = d->GetMesh(); if (mesh) { @@ -158,7 +162,9 @@ void PaintMouseProc::DoPainting(HWND hWnd, IPoint2 m) } } +#if MAX_VERSION_MAJOR < 19 GetCOREInterface()->ReleaseViewport(pView); +#endif } else { SetCursor(hNoPaintCursor); @@ -186,7 +192,11 @@ void PaintMouseProc::DoPickColor(HWND hWnd, IPoint2 m) SetCursor(hDropperCursor); TriObject *pTri = (TriObject *) os.obj; +#if MAX_VERSION_MAJOR >= 19 + ViewExp* pView = &GetCOREInterface()->GetViewExp(hWnd); +#else ViewExp* pView = GetCOREInterface()->GetViewport(hWnd); +#endif Mesh* mesh = &pTri->mesh; if (mesh) { @@ -234,7 +244,9 @@ void PaintMouseProc::DoPickColor(HWND hWnd, IPoint2 m) } } +#if MAX_VERSION_MAJOR < 19 GetCOREInterface()->ReleaseViewport(pView); +#endif } } else { diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp index 3d58b8027..3a513683a 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp @@ -854,10 +854,17 @@ void VertexPaint::fillSelectionGradientColor() // Get Matrix to viewport. Matrix3 viewMat; { +#if MAX_VERSION_MAJOR >= 19 + ViewExp *ve = &GetCOREInterface()->GetActiveViewExp(); +#else ViewExp *ve = GetCOREInterface()->GetActiveViewport(); +#endif // The affine TM transforms from world coords to view coords ve->GetAffineTM(viewMat); + +#if MAX_VERSION_MAJOR < 19 GetCOREInterface()->ReleaseViewport(ve); +#endif }