Skip to content

Commit

Permalink
Merge pull request #409 from orbitersim/toolkit_fixes
Browse files Browse the repository at this point in the history
Toolkit fixes
  • Loading branch information
jarmonik authored Jan 11, 2024
2 parents c31ea84 + 634a878 commit 9439975
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 62 deletions.
4 changes: 2 additions & 2 deletions OVP/D3D9Client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ install(TARGETS D3D9Client
add_subdirectory(samples/DrawOrbits)
add_subdirectory(samples/DX9ExtMFD)
add_subdirectory(samples/GenericCamera)
add_subdirectory(samples/TerrainToolBox)
add_subdirectory(samples/TerrainToolKit)

install(DIRECTORY ${D3D9_SOURCE_DIR}/shaders/ DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Modules/D3D9Client)
install(DIRECTORY ${D3D9_SOURCE_DIR}/samples/DrawOrbits/ DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk/samples/DrawOrbits)
install(DIRECTORY ${D3D9_SOURCE_DIR}/samples/DX9ExtMFD/ DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk/samples/DX9ExtMFD)
install(DIRECTORY ${D3D9_SOURCE_DIR}/samples/GenericCamera/ DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk/samples/GenericCamera)
install(DIRECTORY ${D3D9_SOURCE_DIR}/samples/TerrainToolBox/ DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk/samples/TerrainToolBox)
install(DIRECTORY ${D3D9_SOURCE_DIR}/samples/TerrainToolKit/ DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk/samples/TerrainToolKit)
install(FILES ${INCLUDE_TARGET_DIR}/gcCoreAPI.h DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk/include)
install(FILES ${INCLUDE_TARGET_DIR}/gcGUI.h DESTINATION ${ORBITER_INSTALL_ROOT_DIR}/Orbitersdk/include)
install(FILES ${ORBITER_SOURCE_SDK_DIR}/doc/Orbiter2DGraphics.pdf DESTINATION ${ORBITER_INSTALL_SDK_DIR}/doc)
3 changes: 2 additions & 1 deletion OVP/D3D9Client/D3D9Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,8 @@ void D3D9Client::PushRenderTarget(LPDIRECT3DSURFACE9 pColor, LPDIRECT3DSURFACE9
pDevice->SetViewport(&vp);
}

if (pDepthStencil) if (pDevice->SetDepthStencilSurface(pDepthStencil) != S_OK) assert(false);
// If pDepthStencil is NULL set NULL
if (pDevice->SetDepthStencilSurface(pDepthStencil) != S_OK) assert(false);
if (pColor) if (pDevice->SetRenderTarget(0, pColor) != S_OK) assert(false);

RenderStack.push_front(data);
Expand Down
2 changes: 1 addition & 1 deletion OVP/D3D9Client/D3D9Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void D3D9Config::Reset ()
FrameRate = 200.0;
EnableLimiter = 0;
CustomCamMode = 1;
TileMipmaps = 1;
TileMipmaps = 2;
TextureMips = 1;
LODBias = 0.0;
MeshRes = 1;
Expand Down
8 changes: 4 additions & 4 deletions OVP/D3D9Client/Surfmgr2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,11 +917,11 @@ void SurfTile::Render ()
// DevTools: Render with overlay image
// ----------------------------------------------------------------------

FVECTOR4 texcoord;
const vPlanet::sOverlay *oLay = vPlanet->IntersectOverlay(bnd.vec, &texcoord);

if (pShader->bDevtools)
if (pShader->bDevtools && scene->GetRenderPass() == RENDERPASS_MAINSCENE)
{
FVECTOR4 texcoord;
const vPlanet::sOverlay* oLay = vPlanet->IntersectOverlay(bnd.vec, &texcoord);

if (oLay)
{
bool bOlayEnable = false; for (auto x : oLay->pSurf) if (x) bOlayEnable = true;
Expand Down
14 changes: 9 additions & 5 deletions OVP/D3D9Client/VPlanet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,13 +1340,17 @@ vPlanet::sOverlay * vPlanet::IntersectOverlay(VECTOR4 q, FVECTOR4 *texcoord) con
{
for (auto olay : overlays)
{
if (q.x > olay->lnglat.z) continue;
if (q.z < olay->lnglat.x) continue;
if (q.y < olay->lnglat.w) continue;
if (q.w > olay->lnglat.y) continue;

double ow = fabs(olay->lnglat.x - olay->lnglat.z);
double oh = fabs(olay->lnglat.y - olay->lnglat.w);
double ew = ow * 0.001;
double eh = oh * 0.001;

if (q.x > (olay->lnglat.z - ew)) continue;
if (q.z < (olay->lnglat.x + ew)) continue;
if (q.y < (olay->lnglat.w + eh)) continue;
if (q.w > (olay->lnglat.y - eh)) continue;


double tw = fabs(q.x - q.z);
double th = fabs(q.y - q.w);

Expand Down
1 change: 1 addition & 0 deletions OVP/D3D9Client/VideoTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ void VideoTab::InitSetupDialog(HWND hWnd)
SendDlgItemMessage(hWnd, IDC_MIPMAPS, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageA(hWnd, IDC_MIPMAPS, CB_ADDSTRING, 0, (LPARAM)"None");
SendDlgItemMessageA(hWnd, IDC_MIPMAPS, CB_ADDSTRING, 0, (LPARAM)"Low level only");
SendDlgItemMessageA(hWnd, IDC_MIPMAPS, CB_ADDSTRING, 0, (LPARAM)"All levels");
SendDlgItemMessage(hWnd, IDC_MIPMAPS, CB_SETCURSEL, 0, 0);

// ARCHIVE METHOD ------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "VesselAPI.h"
#include "ModuleAPI.h"
#include "DrawAPI.h"
#include "ToolBox.h"
#include "ToolKit.h"
#include "resource.h"
#include "gcPropertyTree.h"
#include "QTree.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Licensed under the MIT License

add_library(TerrainToolBox MODULE
add_library(TerrainToolKit MODULE
gcPropertyTree.h
gcTableView.cpp
QTree.h
QTree.cpp
ToolBox.h
ToolBox.cpp
ToolBox.rc
ToolKit.h
ToolKit.cpp
ToolKit.rc
ExportImport.cpp
Basics.cpp
Layer.cpp
resource.h
)

add_dependencies(TerrainToolBox
add_dependencies(TerrainToolKit
D3D9Client
)

target_link_libraries(TerrainToolBox
target_link_libraries(TerrainToolKit
${OrbiterTgt}
Orbitersdk
Msimg32.lib
Comctl32.lib
)

target_include_directories(TerrainToolBox
target_include_directories(TerrainToolKit
PUBLIC ${INCLUDE_TARGET_DIR}
)

set_target_properties(TerrainToolBox
set_target_properties(TerrainToolKit
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Modules/Plugin
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Modules/Plugin
FOLDER OVP
)

install(TARGETS TerrainToolBox
install(TARGETS TerrainToolKit
LIBRARY
DESTINATION ${ORBITER_INSTALL_PLUGIN_DIR}
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "ModuleAPI.h"
#include "DrawAPI.h"
#include "gcCoreAPI.h"
#include "ToolBox.h"
#include "ToolKit.h"
#include "resource.h"
#include "gcPropertyTree.h"
#include "QTree.h"
Expand All @@ -30,8 +30,10 @@ BOOL CALLBACK gDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void ToolKit::StopImport()
{
for (auto x : pLr) {
if (x->hSource) oapiReleaseTexture(x->hSource);
x->hSource = NULL;
if (x) {
if (x->hSource) oapiReleaseTexture(x->hSource);
x->hSource = NULL;
}
}

if (hOverlay) pCore->AddGlobalOverlay(hMgr, _V(0, 0, 0, 0), gcCore::OlayType::RELEASE_ALL, NULL, hOverlay);
Expand Down Expand Up @@ -151,7 +153,7 @@ void ToolKit::ExportElev()
void ToolKit::BakeImport()
{

if (MessageBox(pCore->GetRenderWindow(), "Bake and Write the tiles in 'OrbiterRoot/TerrainToolBox/' Folder ?", "Are you sure", MB_YESNO | MB_ICONEXCLAMATION) != IDYES) return;
if (MessageBox(pCore->GetRenderWindow(), "Bake and Write the tiles in 'OrbiterRoot/TerrainToolKit/' Folder ?", "Are you sure", MB_YESNO | MB_ICONEXCLAMATION) != IDYES) return;

bool bWater = IsLayerValid(Layer::LayerType::WATER);
bool bNight = IsLayerValid(Layer::LayerType::NIGHT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "VesselAPI.h"
#include "ModuleAPI.h"
#include "DrawAPI.h"
#include "ToolBox.h"
#include "ToolKit.h"
#include "resource.h"
#include "gcPropertyTree.h"
#include "QTree.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "OrbiterAPI.h"
#include "QTree.h"
#include "ToolBox.h"
#include "ToolKit.h"
#include "gcCoreAPI.h"
#include <stack>

Expand Down Expand Up @@ -340,35 +340,35 @@ int QTree::SaveTile(int flags, SURFHANDLE hSurf, SURFHANDLE hTemp, DRECT bounds,

// ---------------------------------------------------------

DWORD fa = GetFileAttributesA("TerrainToolBox");
if (fa == INVALID_FILE_ATTRIBUTES) CreateDirectoryA("TerrainToolBox", NULL);
DWORD fa = GetFileAttributesA("TerrainToolKit");
if (fa == INVALID_FILE_ATTRIBUTES) CreateDirectoryA("TerrainToolKit", NULL);
else if ((fa & FILE_ATTRIBUTE_DIRECTORY) == 0) return -1;

// ---------------------------------------------------------

sprintf_s(name, 63, "TerrainToolBox\\%s", dir);
sprintf_s(name, 63, "TerrainToolKit\\%s", dir);
fa = GetFileAttributesA(name);
if (fa == INVALID_FILE_ATTRIBUTES) CreateDirectoryA(name, NULL);
else if ((fa & FILE_ATTRIBUTE_DIRECTORY) == 0) return -2;

// ---------------------------------------------------------

sprintf_s(name, 63, "TerrainToolBox\\%s\\%02d", dir, level + 4);
sprintf_s(name, 63, "TerrainToolKit\\%s\\%02d", dir, level + 4);
fa = GetFileAttributesA(name);
if (fa == INVALID_FILE_ATTRIBUTES) CreateDirectoryA(name, NULL);
else if ((fa & FILE_ATTRIBUTE_DIRECTORY) == 0) return -3;

// ---------------------------------------------------------

sprintf_s(name, 63, "TerrainToolBox\\%s\\%02d\\%06d", dir, level +4, ilat);
sprintf_s(name, 63, "TerrainToolKit\\%s\\%02d\\%06d", dir, level +4, ilat);
fa = GetFileAttributesA(name);
if (fa == INVALID_FILE_ATTRIBUTES) CreateDirectoryA(name, NULL);
else if ((fa & FILE_ATTRIBUTE_DIRECTORY) == 0) return -4;


//----------------------------------------------------------

sprintf_s(name, 63, "TerrainToolBox\\%s\\%02d\\%06d\\%06d.dds", dir, level + 4, ilat, ilng);
sprintf_s(name, 63, "TerrainToolKit\\%s\\%02d\\%06d\\%06d.dds", dir, level + 4, ilat, ilng);

Sketchpad *pSkp = oapiGetSketchpad(hTemp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "ModuleAPI.h"
#include "DrawAPI.h"
#include "gcCoreAPI.h"
#include "ToolBox.h"
#include "ToolKit.h"
#include "resource.h"
#include "gcPropertyTree.h"
#include "QTree.h"
Expand Down Expand Up @@ -176,13 +176,6 @@ BOOL ToolKit::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return true;
}

case IDC_UPDATECLIP:
{
if (selection.area.size() != 0) oldsel = selection;
selection.area.clear();
break;
}

case IDC_DATAVIEW:
{
break;
Expand Down Expand Up @@ -251,7 +244,7 @@ ToolKit::ToolKit(HINSTANCE hInst) : gcGUIApp(), Module(hInst)
bGo = false;

// Can do very little here since graphics servises are not yet running
dwCmd = oapiRegisterCustomCmd((char*)"TerrainToolBox", (char*)"ToolBox for terrain and base editing", OpenToolsClbk, this);
dwCmd = oapiRegisterCustomCmd((char*)"TerrainToolKit", (char*)"ToolKit for terrain and base editing", OpenToolsClbk, this);
gcPropertyTreeInitialize(hInst);

mIdent.Ident();
Expand Down Expand Up @@ -418,7 +411,7 @@ bool ToolKit::Initialize()
SendDlgItemMessage(hCtrlDlg, IDC_SELECT, CB_ADDSTRING, 0, (LPARAM)"Heighest Existing"); // 1
SendDlgItemMessage(hCtrlDlg, IDC_SELECT, CB_SETCURSEL, 1, 0);

for (int i = 5; i < 20; i++) {
for (int i = 5; i < 22; i++) {
char Lbl[32]; sprintf_s(Lbl, 32, "Level %d", i);
SendDlgItemMessageA(hCtrlDlg, IDC_SELECT, CB_ADDSTRING, 0, (LPARAM)Lbl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Layer
FVECTOR4 GetColor();
FVECTOR4 GetAdjustments();
double Max(double a, double b, double c, double d);
double Min(double a, double b, double c, double d);
double Min(double a, double b, double c, double d);

SURFHANDLE hSource;
string name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ IDD_IMPORT DIALOG 0, 0, 180, 120
STYLE DS_CENTER | DS_SHELLFONT | WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
FONT 8, "Ms Shell Dlg"
{
PUSHBUTTON "Open Elevation", IDC_OPENELEV, 95, 20, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Open Nightlights", IDC_OPENNIGHT, 95, 5, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Open Mesh", IDC_OPENMESH, 5, 45, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Open Elevation", IDC_OPENELEV, 95, 5, 75, 14, WS_DISABLED, WS_EX_LEFT
PUSHBUTTON "Open Nightlights", IDC_OPENNIGHT, 5, 36, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Open Mesh", IDC_OPENMESH, 96, 21, 75, 14, WS_DISABLED, WS_EX_LEFT
PUSHBUTTON "Open Surface", IDC_OPENIMAGE, 5, 5, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Bake", IDC_BAKE, 95, 100, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Reset Corners", IDC_CORNERS, 95, 60, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Reselect Region", IDC_UPDATECLIP, 95, 45, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Cancel Import", IDC_STOP, 95, 75, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Edit Elevation", IDC_EDITELEV, 5, 100, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Reset Corners", IDC_CORNERS, 95, 83, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Cancel Import", IDC_STOP, 5, 100, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Edit Elevation", IDC_EDITELEV, 95, 36, 75, 14, WS_DISABLED, WS_EX_LEFT
PUSHBUTTON "Open Water", IDC_OPENWATER, 5, 20, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Start Import", IDC_STARTIMPORT, 5, 75, 75, 14, 0, WS_EX_LEFT
PUSHBUTTON "Start Import", IDC_STARTIMPORT, 5, 83, 75, 14, 0, WS_EX_LEFT
}


Expand Down Expand Up @@ -88,7 +87,7 @@ FONT 8, "Ms Shell Dlg"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
STRINGTABLE
{
IDS_INFO "Terrain and Base Development ToolBox"
IDS_INFO "Terrain and Base Development ToolKit"
IDS_TYPE "Developer resources and samples"
}

Expand All @@ -111,12 +110,12 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
{
BLOCK "080904E4"
{
VALUE "FileDescription", "Terrain and Base Development ToolBox"
VALUE "FileDescription", "Terrain and Base Development ToolKit"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "TerrainToolBox"
VALUE "InternalName", "TerrainToolKit"
VALUE "LegalCopyright", "Copyright � 2019"
VALUE "OriginalFilename", "TerrainToolBox.dll"
VALUE "ProductName", "TerrainToolBox"
VALUE "OriginalFilename", "TerrainToolKit.dll"
VALUE "ProductName", "TerrainToolKit"
VALUE "ProductVersion", "1.0.0.0"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define IDC_STATIC (-1)
#endif

#define IDS_INFO 1000 // never change these!
#define IDS_TYPE 1001 // " " "
#define IDD_DATA 102
#define IDD_IMPORT 103
#define IDD_EXPORT 104
Expand All @@ -15,16 +17,13 @@
#define IDC_BAKE 1012
#define IDC_OPENIMAGE 1014
#define IDC_STOP 1015
#define IDC_UPDATECLIP 1018
#define IDC_CORNERS 1020
#define IDC_PROGBAR 1021
#define IDC_LOAD 4000
#define IDC_OPENNIGHT 4001
#define IDS_INFO 4002
#define IDC_DISPSEL 4003
#define IDC_OPENELEV 4004
#define IDC_SAVE 4005
#define IDS_TYPE 4006
#define IDC_OPENMESH 4007
#define IDC_EDITELEV 4008
#define IDC_OPENWATER 4009
Expand Down

0 comments on commit 9439975

Please sign in to comment.