From 593393dd641105efb230a56366c811ae86749352 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 14 Oct 2010 16:57:00 +0000 Subject: [PATCH] speedtree win64 --- dtool/Config.Cygwin.pp | 8 +++----- dtool/Config.Cygwin64.pp | 10 ++++++++++ dtool/Config.pp | 12 ++++++++---- dtool/LocalSetup.pp | 7 +++---- dtool/Package.pp | 8 +++++++- makepanda/makepanda.py | 12 ++++++++++-- panda/src/speedtree/config_speedtree.cxx | 8 ++++++++ panda/src/speedtree/config_speedtree.h | 1 + panda/src/speedtree/speedTreeNode.cxx | 4 ++-- panda/src/speedtree/speedTreeNode.h | 6 ++++-- panda/src/speedtree/stBasicTerrain.cxx | 6 +++--- 11 files changed, 59 insertions(+), 23 deletions(-) create mode 100755 dtool/Config.Cygwin64.pp diff --git a/dtool/Config.Cygwin.pp b/dtool/Config.Cygwin.pp index 1420db98db..11c8729f6e 100644 --- a/dtool/Config.Cygwin.pp +++ b/dtool/Config.Cygwin.pp @@ -5,10 +5,8 @@ // platform, when ppremake has been compiled using Cygwin. It // inherits most of its parameters from Config.Win32.pp. // -// *** UNCOMMENT ONE OF THE TWO OPTIONS BELOW FOR 32 OR 64 BIT BUILDS -// 32-bit +// Note: if you are building for 64-bit Windows, you should configure +// ppremake with the "Cygwin64" platform name instead of "Cygwin". + #include $[THISDIRPREFIX]Config.Win32.pp - -// 64-bit -// #include $[THISDIRPREFIX]Config.Win64.pp diff --git a/dtool/Config.Cygwin64.pp b/dtool/Config.Cygwin64.pp new file mode 100755 index 0000000000..0d77563bd9 --- /dev/null +++ b/dtool/Config.Cygwin64.pp @@ -0,0 +1,10 @@ +// +// Config.Cygwin64.pp +// +// This file defines some custom config variables for the Windows +// platform, when ppremake has been compiled using Cygwin. It +// inherits most of its parameters from Config.Win64.pp. +// + +// 32-bit +#include $[THISDIRPREFIX]Config.Win64.pp diff --git a/dtool/Config.pp b/dtool/Config.pp index 3508732d15..bf5e2c2d35 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -755,8 +755,11 @@ #define DX9_LIBS d3d9.lib d3dx9.lib dxerr9.lib #defer HAVE_DX9 $[libtest $[DX9_LPATH],$[DX9_LIBS]] -// Set this nonempty to use instead of . -#define USE_GENERIC_DXERR_LIBRARY +// Set this nonempty to use instead of . The +// choice between the two is largely based on which version of the +// DirectX SDK(s) you might have installed. The generic library is +// the default for 64-bit windows. +#defer USE_GENERIC_DXERR_LIBRARY $[WIN64_PLATFORM] // Is OpenCV installed, and where? #define OPENCV_IPATH /usr/local/include/opencv @@ -951,12 +954,13 @@ #defer SPEEDTREE_BIN_DIR $[SPEEDTREE_SDK_DIR]/Bin #defer SPEEDTREE_IPATH $[SPEEDTREE_SDK_DIR]/Include -#defer SPEEDTREE_LPATH $[SPEEDTREE_SDK_DIR]/Lib/Windows/VC9 +#defer SPEEDTREE_LPATH $[SPEEDTREE_SDK_DIR]/Lib/Windows/VC9$[if $[WIN64_PLATFORM],.x64] #defer SPEEDTREE_DEBUG $[if $[< $[OPTIMIZE], 3],_d] +#defer SPEEDTREE_64 $[if $[WIN64_PLATFORM],64] // These names are used to build up the names of the SpeedTree libraries. #defer SPEEDTREE_VERSION 5.1 -#defer SPEEDTREE_LIB_SUFFIX _v$[SPEEDTREE_VERSION]_VC90MT_Static$[SPEEDTREE_DEBUG].lib +#defer SPEEDTREE_LIB_SUFFIX _v$[SPEEDTREE_VERSION]_VC90MT$[SPEEDTREE_64]_Static$[SPEEDTREE_DEBUG].lib #if $[WINDOWS_PLATFORM] #defer SPEEDTREE_LIBS SpeedTreeCore$[SPEEDTREE_LIB_SUFFIX] SpeedTreeForest$[SPEEDTREE_LIB_SUFFIX] SpeedTree$[SPEEDTREE_API]Renderer$[SPEEDTREE_LIB_SUFFIX] SpeedTreeRenderInterface$[SPEEDTREE_LIB_SUFFIX] $[if $[eq $[SPEEDTREE_API],OpenGL],glew32.lib] #else diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index eaabe5db13..c5177ccaa3 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -389,10 +389,9 @@ $[cdefine HAVE_DX8] /* Define if we have DirectX installed and want to build for DX. */ $[cdefine HAVE_DX9] -/* If we're building 64-bit, we want to use generic DirectX error libraries. */ -#if $[eq $[USE_COMPILER],MSVC9x64] - $[cdefine USE_GENERIC_DXERR_LIBRARY] -#endif +/* The choice of generic vs. the specific dxerr library largely + depends on which SDK you have installed. */ +$[cdefine USE_GENERIC_DXERR_LIBRARY] /* Define if we want to build tinydisplay. */ $[cdefine HAVE_TINYDISPLAY] diff --git a/dtool/Package.pp b/dtool/Package.pp index d002a49047..115e5cc57b 100644 --- a/dtool/Package.pp +++ b/dtool/Package.pp @@ -74,8 +74,14 @@ // PLATFORM variable, and help it to control the effects of functions // like $[os] and $[isfullpath]. +// True if we are specifically 32-bit Windows. +#define WIN32_PLATFORM $[or $[eq $[PLATFORM],Win32],$[eq $[PLATFORM],Cygwin]] + +// True if we are 64-bit windows. +#define WIN64_PLATFORM $[or $[eq $[PLATFORM],Win64],$[eq $[PLATFORM],Cygwin64]] + // True if we are building on some flavor of Windows. -#define WINDOWS_PLATFORM $[or $[eq $[PLATFORM],Win32],$[eq $[PLATFORM],Cygwin]] +#define WINDOWS_PLATFORM $[or $[WIN32_PLATFORM],$[WIN64_PLATFORM]] // True if we are building on some flavor of OS X. #define OSX_PLATFORM $[eq $[PLATFORM],OSX] diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index e2c98c96cc..3545381e7f 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -458,10 +458,18 @@ if (COMPILER=="MSVC"): # We need to be able to find NxCharacter.dll when importing code library libpandaphysx AddToPathEnv("PATH", SDK["PHYSX"]+"/../Bin/win32/") if (PkgSkip("SPEEDTREE")==0): - libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC9/" + win64 = (sys.platform.startswith("win") and platform.architecture()[0] == "64bit") + if win64: + libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC9.x64/" + p64ext = '64' + else: + libdir = SDK["SPEEDTREE"] + "/Lib/Windows/VC9/" + p64ext = '' + debugext = '' if (GetOptimize() <= 2 and sys.platform.startswith("win")): debugext = "_d" - libsuffix = "_v%s_VC90MT_Static%s.lib" % (SDK["SPEEDTREEVERSION"], debugext) + libsuffix = "_v%s_VC90MT%s_Static%s.lib" % ( + SDK["SPEEDTREEVERSION"], p64ext, debugext) LibName("SPEEDTREE", "%sSpeedTreeCore%s" % (libdir, libsuffix)) LibName("SPEEDTREE", "%sSpeedTreeForest%s" % (libdir, libsuffix)) LibName("SPEEDTREE", "%sSpeedTree%sRenderer%s" % (libdir, SDK["SPEEDTREEAPI"], libsuffix)) diff --git a/panda/src/speedtree/config_speedtree.cxx b/panda/src/speedtree/config_speedtree.cxx index a6d8d0eb6f..16991d5a10 100644 --- a/panda/src/speedtree/config_speedtree.cxx +++ b/panda/src/speedtree/config_speedtree.cxx @@ -231,6 +231,14 @@ ConfigVariableDouble speedtree_cull_cell_size "while increasing the number of trees that are rendered " "per call.")); +ConfigVariableDouble speedtree_area_scale +("speedtree-area-scale", 3280.839895013, + PRC_DESC("This is the factor by which the \"area\" value in a SpeedTree " + "terrain.txt file is scaled (after taking its square root) " + "when loading a new terrain. The default is about 3281, which " + "scales from kilometers to feet. You should set a different " + "scale if you use units other than feet.")); + ConfigVariableBool speedtree_5_2_stf ("speedtree-5-2-stf", #if SPEEDTREE_VERSION_MAJOR > 5 || (SPEEDTREE_VERSION_MAJOR == 5 && SPEEDTREE_VERSION_MINOR >= 2) diff --git a/panda/src/speedtree/config_speedtree.h b/panda/src/speedtree/config_speedtree.h index bcee2cfc2a..97b4dbeec2 100644 --- a/panda/src/speedtree/config_speedtree.h +++ b/panda/src/speedtree/config_speedtree.h @@ -69,6 +69,7 @@ extern ConfigVariableBool speedtree_show_overlays; extern ConfigVariableInt speedtree_max_num_visible_cells; extern ConfigVariableDouble speedtree_cull_cell_size; +extern ConfigVariableDouble speedtree_area_scale; extern ConfigVariableBool speedtree_5_2_stf; extern EXPCL_PANDASPEEDTREE void init_libspeedtree(); diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index b0d2c077f4..0f9ee6fa81 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -106,7 +106,7 @@ SpeedTreeNode(const string &name) : _os_shaders_dir = shaders_dir.to_os_specific(); // Ensure the path ends with a terminal slash; SpeedTree requires this. -#ifdef WIN32 +#if defined(WIN32) || defined(WIN64) if (!_os_shaders_dir.empty() && _os_shaders_dir[_os_shaders_dir.length() - 1] != '\\') { _os_shaders_dir += "\\"; } @@ -1604,7 +1604,7 @@ setup_for_render(GraphicsStateGuardian *gsg) { if (!speedtree_textures_dir.empty()) { os_textures_dir = speedtree_textures_dir.get_value().to_os_specific(); // Ensure the path ends with a terminal slash; SpeedTree requires this. -#ifdef WIN32 +#if defined(WIN32) || defined(WIN64) if (!os_textures_dir.empty() && os_textures_dir[os_textures_dir.length() - 1] != '\\') { os_textures_dir += "\\"; } diff --git a/panda/src/speedtree/speedTreeNode.h b/panda/src/speedtree/speedTreeNode.h index ab98b32840..764b96e8f1 100644 --- a/panda/src/speedtree/speedTreeNode.h +++ b/panda/src/speedtree/speedTreeNode.h @@ -45,8 +45,10 @@ class Loader; // SpeedTree objects, especially trees, within the // Panda3D scene graph. // -// SpeedTree also includes some support for simple -// terrain and grass systems. +// SpeedTree also includes some support for a simple +// terrain system, which is available here as well. +// SpeedTree's rather lame grass system is not presently +// exposed. //////////////////////////////////////////////////////////////////// class EXPCL_PANDASPEEDTREE SpeedTreeNode : public PandaNode { private: diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index 15427e7dbd..6b01668347 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -159,11 +159,11 @@ setup_terrain(istream &in, const Filename &pathname) { in >> keyword; while (in && !in.eof()) { if (keyword == "area") { - // area defines the size of the terrain in square kilometers. - static const float feet_per_km = 3280.839895013f; + // "area" defines the size of the terrain in square kilometers. + // We apply speedtree_area_scale to convert that to local units. float area; in >> area; - _size = csqrt(area) * feet_per_km; + _size = csqrt(area) * speedtree_area_scale; } else if (keyword == "height_scale") { in >> _height_scale;