Skip to content

Commit

Permalink
Update lpub3d_build branch to master commit 0f529ca
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Oct 2, 2024
1 parent 039313c commit 0d83549
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 43 deletions.
30 changes: 17 additions & 13 deletions LDExporter/LDPovExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 6 additions & 2 deletions LDExporter/LDPovExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 7 additions & 6 deletions LDLoader/LDLModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1260,7 +1261,7 @@ void LDLModel::initCheckDirs()
}
#ifdef WIN32
char buf[1024];

if (GetPrivateProfileString("LDraw", "BaseDirectory", "", buf, 1024,
"ldraw.ini"))
{
Expand All @@ -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);
Expand Down Expand Up @@ -2870,7 +2871,7 @@ void LDLModel::scanPoints(
if (step >= 0 && fileLine->getLineType() == LDLLineTypeComment)
{
LDLCommentLine *commentLine = (LDLCommentLine *)fileLine;

if (commentLine->isStepMeta() && !emptyStep)
{
emptyStep = true;
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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))
{
Expand Down
61 changes: 39 additions & 22 deletions OSMesa/ldview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <unistd.h>
#include <string>
#include <map>

// LPub3D Mod - version info
#ifdef VERSION_INFO
#ifdef ARCH
char LDViewVersion[] = VERSION_INFO " (" ARCH ") ";
Expand All @@ -15,33 +15,37 @@ char LDViewVersion[] = VERSION_INFO " ";
#else
char LDViewVersion[] = "4.5.0 ";
#endif

// LPub3D Mod End
#include <TCFoundation/TCUserDefaults.h>
#include <TCFoundation/mystring.h>
#include <LDLib/LDSnapshotTaker.h>
#include <LDLoader/LDLModel.h>
#include <TCFoundation/TCAutoreleasePool.h>
#include <TCFoundation/TCAlertManager.h>
#include <TCFoundation/TCProgressAlert.h>
#include <TCFoundation/TCLocalStrings.h>
#include <LDLib/LDSnapshotTaker.h>
#include <LDLoader/LDLModel.h>

// LPub3D Mod - Main includes
#if defined (__APPLE__)
#include <GLUT/glut.h>
#endif
#ifndef GLAPIENTRY
#define GLAPIENTRY
#endif

// LPub3D Mod End
#include <GL/osmesa.h>
#include <TRE/TREMainModel.h>
// LPub3D Mod - Main includes
#include <GLInfo.h>
// LPub3D Mod End
#include "StudLogo.h"
#include "LDViewMessages.h"

// LPub3D Mod - Main includes
#ifdef __USE_GNU
#include <errno.h>
#include <stdlib.h>
#endif
// LPub3D Mod End

typedef std::map<std::string, std::string> StringMap;

Expand Down Expand Up @@ -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 )
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
Expand All @@ -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 = ");
Expand All @@ -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();
Expand Down

0 comments on commit 0d83549

Please sign in to comment.