From 0d835491d5077891a2b73fad7a6e0798f06d507c Mon Sep 17 00:00:00 2001 From: Trevor SANDY Date: Wed, 2 Oct 2024 12:39:25 +0200 Subject: [PATCH] Update lpub3d_build branch to master commit 0f529ca --- LDExporter/LDPovExporter.cpp | 30 ++++++++++-------- LDExporter/LDPovExporter.h | 8 +++-- LDLoader/LDLModel.cpp | 13 ++++---- OSMesa/ldview.cpp | 61 +++++++++++++++++++++++------------- 4 files changed, 69 insertions(+), 43 deletions(-) diff --git a/LDExporter/LDPovExporter.cpp b/LDExporter/LDPovExporter.cpp index 594cd124..0a463c7d 100644 --- a/LDExporter/LDPovExporter.cpp +++ b/LDExporter/LDPovExporter.cpp @@ -347,14 +347,14 @@ void LDPovExporter::loadSettings(void) { m_bottomInclude = ""; } - // LPub3D Mod - lights + // LPub3D Mod - lights temp = stringForKey("PovLights", EXPORT_POV_LIGHTS_DEFAULT); if (temp != NULL) { loadLights(temp); delete[] temp; } - // LPub3D Mod End + // LPub3D Mod End } LDExporterSetting *LDPovExporter::addEdgesSettings( @@ -523,7 +523,7 @@ void LDPovExporter::initSettings(void) const addSetting(pGroup, ls(_UC("PovDiffuse")), m_diffuse, udKey("Diffuse").c_str(), 0.0f, 1.0f); - // LPub3D Mod - lights + // LPub3D Mod - lights pGroup = addSettingGroup(ls(_UC("PovLights"))); if (pGroup == NULL) { @@ -533,7 +533,7 @@ void LDPovExporter::initSettings(void) const addSetting(pGroup, LDExporterSetting(ls(_UC("PovLights")), lightString.c_str(), udKey("PovLights").c_str())); m_settings.back().setTooltip("PovLightsTT"); - // LPub3D Mod End + // LPub3D Mod End pGroup = addSettingGroup(ls(_UC("PovMaterialProps"))); if (pGroup == NULL) @@ -648,8 +648,8 @@ void LDPovExporter::loadLights(const char* povLights) int rows; int columns; int attributes = sscanf(value, "%d %d %f %f %s %s %f %f %f %f %f %f %d %d %d %d %d", - &type, &shadowless, &latitude, &longitude, target, color, &intensity, &fadeDistance, - &fadePower, &radius, &falloff, &tightness, &circle, &width, &height, &rows, &columns); + &type, &shadowless, &latitude, &longitude, target, color, &intensity, &fadeDistance, + &fadePower, &radius, &falloff, &tightness, &circle, &width, &height, &rows, &columns); if (value && attributes == 17) { Light light { type, shadowless, latitude, longitude, target, color, intensity, fadeDistance, @@ -1026,23 +1026,23 @@ int LDPovExporter::doExport(LDLModel *pTopModel) { return 1; } - // LPub3D Mod - global settings - writeGlobalSettings(); - // LPub3D Mod End + // LPub3D Mod - global settings + writeGlobalSettings(); + // LPub3D Mod End if (m_topInclude.size() > 0) { fprintf(m_pPovFile, "#include \"%s\"\n\n", m_topInclude.c_str()); } - // LPub3D Mod - lgQuality + // LPub3D Mod - lgQuality writeLgQuality(); - // LPub3D Mod End + // LPub3D Mod End if (!writeCamera()) { return 1; } - // LPub3D Mod - light source macro + // LPub3D Mod - light source macro writeLightSourceMacro(); - // LPub3D Mod End + // LPub3D Mod End if (!writeLights()) { return 1; @@ -1298,6 +1298,10 @@ bool LDPovExporter::writeHeader(void) } fprintf(m_pPovFile, ls("PovNote"), m_appName.c_str()); fprintf(m_pPovFile, "#version %g;\n\n", m_fileVersion); + // LPub3D Mod - global settings + // Moved to writeGlobalSettings macro + // fprintf(m_pPovFile, "#if (version >= 3.7) global_settings {assumed_gamma 1} #end\n\n"); + // LPub3D Mod End writeDeclare("LDXQual", m_quality, "PovQualDesc"); writeDeclare("LDXSW", m_seamWidth, "PovSeamWidthDesc"); writeDeclare("LDXStuds", !m_hideStuds, "PovStudsDesc"); diff --git a/LDExporter/LDPovExporter.h b/LDExporter/LDPovExporter.h index 4faca008..86b63f9f 100644 --- a/LDExporter/LDPovExporter.h +++ b/LDExporter/LDPovExporter.h @@ -191,16 +191,20 @@ class LDPovExporter : public LDExporter ~LDPovExporter(void); void dealloc(void); bool writeHeader(void); - // LPub3D Mod - additional POV-Ray export settings + // LPub3D Mod - additional POV-Ray export settings void writeLgQuality(void); void writeGlobalSettings(void); void writeLightSourceMacro(void); - // LPub3D Mod End + // LPub3D Mod End void writeMainModel(void); void writeFloor(void); bool writeModel(LDLModel *pModel, const TCFloat *matrix, bool inPart); bool writeCamera(void); bool writeLights(void); + // LPub3D Mod - lights + // Replaced with writeLightSourceMacro() + // void writeLight(TCFloat lat, TCFloat lon, int num); + // LPub3D Mod End bool writeModelObject(LDLModel *pModel, bool mirrored, const TCFloat *matrix, bool inPart); void writeGeometry(IntShapeListMap &colorGeometryMap); diff --git a/LDLoader/LDLModel.cpp b/LDLoader/LDLModel.cpp index eb04771f..dbbdb8c1 100644 --- a/LDLoader/LDLModel.cpp +++ b/LDLoader/LDLModel.cpp @@ -1071,7 +1071,8 @@ bool LDLModel::initializeNewSubModel( // LPub3D Mod End bool zipValid = zipStream != NULL && zipStream->is_valid(); // LPub3D Mod - stud style - if (!studStylePrimitive && (subModelStream.is_open() || zipValid) && !subModel->load(subModelStream)) + if (!studStylePrimitive && (subModelStream.is_open() || zipValid) && + !subModel->load(subModelStream, zipStream)) { // LPub3D Mod End subModelDict->removeObjectForKey(dictName); @@ -1260,7 +1261,7 @@ void LDLModel::initCheckDirs() } #ifdef WIN32 char buf[1024]; - + if (GetPrivateProfileString("LDraw", "BaseDirectory", "", buf, 1024, "ldraw.ini")) { @@ -1284,7 +1285,7 @@ void LDLModel::initCheckDirs() if (homeDir != NULL) { char *homeLib = copyString(homeDir, strlen(libDir)); - + stripTrailingPathSeparators(homeLib); strcat(homeLib, libDir); sm_checkDirs.push_back(homeLib); @@ -2870,7 +2871,7 @@ void LDLModel::scanPoints( if (step >= 0 && fileLine->getLineType() == LDLLineTypeComment) { LDLCommentLine *commentLine = (LDLCommentLine *)fileLine; - + if (commentLine->isStepMeta() && !emptyStep) { emptyStep = true; @@ -3164,7 +3165,7 @@ bool LDLModel::searchNext( if (child->getLineType() == LDLLineTypeModel) { LDLModel *childModel = ((LDLModelLine *)child)->getModel(); - + if (childModel != NULL && childModel->searchNext(searchString, childPath, -1, activeLineTypes)) { @@ -3222,7 +3223,7 @@ bool LDLModel::searchPrevious( if (child->getLineType() == LDLLineTypeModel) { LDLModel *childModel = ((LDLModelLine *)child)->getModel(); - + if (childModel != NULL && childModel->searchPrevious(searchString, childPath, -1, activeLineTypes)) { diff --git a/OSMesa/ldview.cpp b/OSMesa/ldview.cpp index 7d9adb1c..34a050a6 100644 --- a/OSMesa/ldview.cpp +++ b/OSMesa/ldview.cpp @@ -5,7 +5,7 @@ #include #include #include - +// LPub3D Mod - version info #ifdef VERSION_INFO #ifdef ARCH char LDViewVersion[] = VERSION_INFO " (" ARCH ") "; @@ -15,33 +15,37 @@ char LDViewVersion[] = VERSION_INFO " "; #else char LDViewVersion[] = "4.5.0 "; #endif - +// LPub3D Mod End #include #include +#include +#include #include #include #include #include -#include -#include +// LPub3D Mod - Main includes #if defined (__APPLE__) #include #endif #ifndef GLAPIENTRY #define GLAPIENTRY #endif - +// LPub3D Mod End #include #include +// LPub3D Mod - Main includes #include +// LPub3D Mod End #include "StudLogo.h" #include "LDViewMessages.h" - +// LPub3D Mod - Main includes #ifdef __USE_GNU #include #include #endif +// LPub3D Mod End typedef std::map StringMap; @@ -76,34 +80,39 @@ class ProgressHandler: public TCObject } }; +// LPub3D Mod - process ini file std::string iniFileStatus(const char *iniPath ) { #ifdef __USE_GNU - errno = 0; + errno = 0; #endif - FILE *iniFile = ucfopen(iniPath, "r+b"); + FILE *iniFile = ucfopen(iniPath, "r+b"); - if (!iniFile) - { + if (!iniFile) + { #ifdef __USE_GNU - return formatString("%s: Could not open file %s; %s", - program_invocation_short_name, iniPath, strerror(errno)); + return formatString("%s: Could not open file %s; %s", + program_invocation_short_name, iniPath, strerror(errno)); #else - return formatString("LDView: Cound not open file %s", iniPath); + return formatString("LDView: Cound not open file %s", iniPath); #endif - } - // we should never get here, but if we do ... - return NULL; + } + // we should never get here, but if we do ... + return NULL; } +// LPub3D Mod End +// LPub3D Mod - process ini file int setupDefaults(char *argv[]) { int retVal = 0; +// LPub3D Mod End TCUserDefaults::setCommandLine(argv); // IniFile can be specified on the command line; if so, don't load a // different one. if (!TCUserDefaults::isIniFileSet()) { + // LPub3D Mod - process ini file // Check if IniFile specified on command line ... std::string iniFile = TCUserDefaults::commandLineStringForKey("IniFile"); if (iniFile.size() > 0 ) @@ -112,11 +121,13 @@ int setupDefaults(char *argv[]) printf("Could not set command line INI file. Returned message:\n" " - %s\n - ldview: Checking for user INI files...\n", fileMsg.c_str()); } + // LPub3D Mod End char *homeDir = getenv("HOME"); if (homeDir) { + // LPub3D Mod - process ini file bool iniFileSet = false; char *rcFile = copyString(homeDir, 128); @@ -158,17 +169,22 @@ int setupDefaults(char *argv[]) retVal = 1; } delete rcFile; + // LPub3D Mod End delete rcFile2; } else { printf("HOME environment variable not defined: cannot use " "~/.ldviewrc.\n"); + // LPub3D Mod - process ini file retVal = 1; + // LPub3D Mod End } } setDebugLevel(TCUserDefaults::longForKey("DebugLevel", 0, false)); + // LPub3D Mod - process ini file return retVal; + // LPub3D Mod End } void *setupContext(OSMesaContext &ctx) @@ -336,19 +352,20 @@ bool fileCaseCallback(char *filename) int main(int argc, char *argv[]) { + // LPub3D Mod - print header and arguments printf("\nLDView - LPub3D Edition CUI (Offscreen Renderer) Version %s\n", LDViewVersion); printf("=========================================\n"); - + bool defaultsKO = false; + // LPub3D Mod End void *buffer; OSMesaContext ctx; int stringTableSize = sizeof(LDViewMessages_bytes); char *stringTable = new char[sizeof(LDViewMessages_bytes) + 1]; - bool defaultsKO = false; memcpy(stringTable, LDViewMessages_bytes, stringTableSize); stringTable[stringTableSize] = 0; TCLocalStrings::setStringTable(stringTable); - + // LPub3D Mod - setup defaults if (setupDefaults(argv) != 0) { if (TCUserDefaults::boolForKey("Info")) @@ -360,11 +377,11 @@ int main(int argc, char *argv[]) return 1; } } - + // LPub3D Mod End if ((buffer = setupContext(ctx)) != NULL) { //ProgressHandler *progressHandler = new ProgressHandler; - + // LPub3D Mod - setup defaults and print GL info if (TCUserDefaults::boolForKey("Info")) { printf("Arguments = "); @@ -390,13 +407,13 @@ int main(int argc, char *argv[]) { return 1; } + // LPub3D Mod End TREMainModel::setStudTextureData(StudLogo_bytes, sizeof(StudLogo_bytes)); LDLModel::setFileCaseCallback(fileCaseCallback); LDSnapshotTaker::doCommandLine(); OSMesaDestroyContext(ctx); free(buffer); - //TCObject::release(progressHandler); } TCAutoreleasePool::processReleases();