Merge branch 'development' of https://github.com/TorqueGameEngines/Torque3D into alpha41/cmake_adjustments

This commit is contained in:
AzaezelX 2023-06-08 13:31:34 -05:00
commit 52093cbde5
25 changed files with 530 additions and 266 deletions

View file

@ -275,6 +275,8 @@ public:
/// Returns the datablock for this object.
GameBaseData* getDataBlock() { return mDataBlock; }
/// returns the datablock name for this object
StringTableEntry getTypeHint() const override { return (mDataBlock) ? mDataBlock->getName() : StringTable->EmptyString(); };
/// Called when a new datablock is set. This allows subclasses to
/// appropriately handle new datablocks.
///

View file

@ -166,6 +166,8 @@ class SpawnSphere : public MissionMarker
bool mAutoSpawn;
bool mSpawnTransform;
/// returns the datablock spawned for this object
StringTableEntry getTypeHint() const override { return (mSpawnDataBlock.isNotEmpty()) ? mSpawnDataBlock.c_str() : StringTable->EmptyString(); };
// Radius/weight info
F32 mRadius;
F32 mSphereWeight;

View file

@ -93,6 +93,10 @@ void Prefab::initPersistFields()
Parent::initPersistFields();
}
StringTableEntry Prefab::getTypeHint() const
{
return (mFilename != StringTable->EmptyString()) ? StringTable->insert(Torque::Path(mFilename).getFileName().c_str()) : StringTable->EmptyString();
}
extern bool gEditingMission;
bool Prefab::onAdd()

View file

@ -60,6 +60,9 @@ public:
static void initPersistFields();
/// returns the filename for this object
StringTableEntry getTypeHint() const override;
// SimObject
virtual bool onAdd();
virtual void onRemove();

View file

@ -106,6 +106,8 @@ class SFXEmitter : public SceneObject
DECLARE_SOUNDASSET(SFXEmitter, Sound);
DECLARE_ASSET_NET_SETGET(SFXEmitter, Sound, DirtyUpdateMask);
/// returns the shape asset used for this object
StringTableEntry getTypeHint() const override { return (getSoundAsset()) ? getSoundAsset()->getAssetName() : StringTable->EmptyString(); }
/// The sound source for the emitter.
SFXSource *mSource;

View file

@ -237,6 +237,8 @@ public:
DECLARE_CONOBJECT(TSStatic);
static void initPersistFields();
/// returns the shape asset used for this object
StringTableEntry getTypeHint() const override { return (getShapeAsset()) ? getShapeAsset()->getAssetName(): StringTable->EmptyString(); }
static void consoleInit();
static bool _setFieldSkin(void* object, const char* index, const char* data);
static const char* _getFieldSkin(void* object, const char* data);

View file

@ -738,7 +738,7 @@ DefineEngineFunction( strrepeat, const char*, ( const char* str, S32 numTimes, c
{
StringBuilder result;
bool isFirst = false;
for( U32 i = 0; i < numTimes; ++ i )
for( S32 i = 0; i < numTimes; ++ i )
{
if( !isFirst )
result.append( delimiter );

View file

@ -549,6 +549,9 @@ class SimObject: public ConsoleObject, public TamlCallbacks
/// Get the internal name of this control
StringTableEntry getInternalName() const { return mInternalName; }
/// type-specified slot for returning hints for the main difference between object instances
virtual StringTableEntry getTypeHint() const { return StringTable->EmptyString(); }
/// Set the original name of this control
void setOriginalName(const char* originalName);

View file

@ -56,8 +56,8 @@ GFXGLTextureObject::GFXGLTextureObject(GFXDevice * aDevice, GFXTextureProfile *p
glGenBuffers(1, &mBuffer);
}
GFXGLTextureObject::~GFXGLTextureObject()
{
GFXGLTextureObject::~GFXGLTextureObject()
{
glDeleteTextures(1, &mHandle);
glDeleteBuffers(1, &mBuffer);
delete[] mZombieCache;
@ -81,7 +81,7 @@ GFXLockedRect* GFXGLTextureObject::lock(U32 mipLevel, RectI *inRect)
{
mLockedRectRect = RectI(0, 0, width, height);
}
mLockedRect.pitch = mLockedRectRect.extent.x * mBytesPerTexel;
// CodeReview [ags 12/19/07] This one texel boundary is necessary to keep the clipmap code from crashing. Figure out why.
@ -93,7 +93,7 @@ GFXLockedRect* GFXGLTextureObject::lock(U32 mipLevel, RectI *inRect)
#ifdef TORQUE_DEBUG
mFrameAllocatorMarkGuard = FrameAllocator::getWaterMark();
#endif
if( !mLockedRect.bits )
return NULL;
@ -117,12 +117,12 @@ void GFXGLTextureObject::unlock(U32 mipLevel)
glTexSubImage3D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y, z,
mLockedRectRect.extent.x, mLockedRectRect.extent.y, z, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
else if(mBinding == GL_TEXTURE_2D)
glTexSubImage2D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y,
glTexSubImage2D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y,
mLockedRectRect.extent.x, mLockedRectRect.extent.y, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
else if(mBinding == GL_TEXTURE_1D)
glTexSubImage1D(mBinding, mipLevel, (mLockedRectRect.point.x > 1 ? mLockedRectRect.point.x : mLockedRectRect.point.y),
glTexSubImage1D(mBinding, mipLevel, (mLockedRectRect.point.x > 1 ? mLockedRectRect.point.x : mLockedRectRect.point.y),
(mLockedRectRect.extent.x > 1 ? mLockedRectRect.extent.x : mLockedRectRect.extent.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
mLockedRect.bits = NULL;
@ -138,7 +138,7 @@ void GFXGLTextureObject::release()
{
glDeleteTextures(1, &mHandle);
glDeleteBuffers(1, &mBuffer);
mHandle = 0;
mBuffer = 0;
}
@ -174,7 +174,7 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
U8 srcBytesPerPixel = GFXFormat_getByteSize( mFormat );
FrameAllocatorMarker mem;
U32 mipLevels = getMipLevels();
for (U32 mip = 0; mip < mipLevels; mip++)
@ -204,7 +204,7 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
}
}
}
glBindTexture(mBinding, NULL);
glBindTexture(mBinding, 0);
return true;
}
@ -236,8 +236,8 @@ U8* GFXGLTextureObject::getTextureData( U32 mip )
AssertFatal( mMipLevels, "");
mip = (mip < mMipLevels) ? mip : 0;
const U32 dataSize = ImageUtil::isCompressedFormat(mFormat)
? getCompressedSurfaceSize( mFormat, mTextureSize.x, mTextureSize.y, mip )
const U32 dataSize = ImageUtil::isCompressedFormat(mFormat)
? getCompressedSurfaceSize( mFormat, mTextureSize.x, mTextureSize.y, mip )
: (mTextureSize.x >> mip) * (mTextureSize.y >> mip) * mBytesPerTexel;
U8* data = new U8[dataSize];
@ -258,10 +258,10 @@ void GFXGLTextureObject::copyIntoCache()
U32 cacheSize = mTextureSize.x * mTextureSize.y;
if(mBinding == GL_TEXTURE_3D)
cacheSize *= mTextureSize.z;
cacheSize *= mBytesPerTexel;
mZombieCache = new U8[cacheSize];
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache);
}
@ -269,7 +269,7 @@ void GFXGLTextureObject::reloadFromCache()
{
if(!mZombieCache)
return;
if(mBinding == GL_TEXTURE_3D)
{
static_cast<GFXGLTextureManager*>(TEXMGR)->_loadTexture(this, mZombieCache);
@ -277,7 +277,7 @@ void GFXGLTextureObject::reloadFromCache()
mZombieCache = NULL;
return;
}
PRESERVE_TEXTURE(mBinding);
glBindTexture(mBinding, mHandle);
@ -285,10 +285,10 @@ void GFXGLTextureObject::reloadFromCache()
glTexSubImage2D(mBinding, 0, 0, 0, mTextureSize.x, mTextureSize.y, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache);
else if(mBinding == GL_TEXTURE_1D)
glTexSubImage1D(mBinding, 0, 0, (mTextureSize.x > 1 ? mTextureSize.x : mTextureSize.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache);
if(mMipLevels != 1)
glGenerateMipmap(mBinding);
delete[] mZombieCache;
mZombieCache = NULL;
mIsZombie = false;
@ -298,11 +298,11 @@ void GFXGLTextureObject::zombify()
{
if(mIsZombie)
return;
mIsZombie = true;
if(!mProfile->doStoreBitmap() && !mProfile->isRenderTarget() && !mProfile->isDynamic() && !mProfile->isZTarget())
copyIntoCache();
release();
}
@ -310,7 +310,7 @@ void GFXGLTextureObject::resurrect()
{
if(!mIsZombie)
return;
glGenTextures(1, &mHandle);
glGenBuffers(1, &mBuffer);
}
@ -329,6 +329,6 @@ const String GFXGLTextureObject::describeSelf() const
{
String ret = Parent::describeSelf();
ret += String::ToString(" GL Handle: %i", mHandle);
return ret;
}

View file

@ -425,6 +425,7 @@ U32 GuiTreeViewCtrl::Item::getDisplayTextLength()
StringTableEntry name = obj->getName();
StringTableEntry internalName = obj->getInternalName();
StringTableEntry typeHint = obj->getTypeHint();
StringTableEntry className = obj->getClassName();
if( showInternalNameOnly() )
@ -466,6 +467,11 @@ U32 GuiTreeViewCtrl::Item::getDisplayTextLength()
if( internalName && internalName[ 0 ] )
len += dStrlen( internalName ) + 3; // ' [<internalname>]'
}
if ( mState.test(ShowTypeHint) )
{
if (typeHint && typeHint[0])
len += dStrlen(typeHint) + 3;
}
if( mState.test( Marked ) )
{
len += 1; // '*<name>'
@ -502,8 +508,10 @@ void GuiTreeViewCtrl::Item::getDisplayText(U32 bufLen, char *buf)
{
const char* pObjName = pObject->getName();
const char* pInternalName = pObject->getInternalName();
const char* pTypeHint = pObject->getTypeHint();
bool hasInternalName = pInternalName && pInternalName[0];
bool hasTypeHint = pTypeHint && pTypeHint[0];
bool hasObjectName = pObjName && pObjName[0];
const char* pClassName = pObject->getClassName();
@ -566,6 +574,14 @@ void GuiTreeViewCtrl::Item::getDisplayText(U32 bufLen, char *buf)
else
dSprintf(ptr, len, " [%s]", pInternalName);
}
if (hasTypeHint && mState.test(ShowTypeHint))
{
if (mState.test(Item::Marked))
dSprintf(ptr, len, " *<%s>", pTypeHint);
else
dSprintf(ptr, len, " <%s>", pTypeHint);
}
}
}
else
@ -835,6 +851,7 @@ GuiTreeViewCtrl::GuiTreeViewCtrl()
mShowClassNames = true;
mShowObjectNames = true;
mShowInternalNames = true;
mShowTypeHints = false;
mShowClassNameForUnnamedObjects = false;
mFlags.set(RebuildVisible);
@ -894,7 +911,10 @@ void GuiTreeViewCtrl::initPersistFields()
addField( "showObjectNames", TypeBool, Offset( mShowObjectNames, GuiTreeViewCtrl ),
"If true, item text labels for objects will include object names." );
addField( "showInternalNames", TypeBool, Offset( mShowInternalNames, GuiTreeViewCtrl ),
"If true, item text labels for obje ts will include internal names." );
"If true, item text labels for objets will include internal names." );
addField("showTypeHints", TypeBool, Offset(mShowTypeHints, GuiTreeViewCtrl),
"If true, item text labels for objets will include TypeHints.");
addField( "showClassNameForUnnamedObjects", TypeBool, Offset( mShowClassNameForUnnamedObjects, GuiTreeViewCtrl ),
"If true, class names will be used as object names for unnamed objects." );
addField( "compareToObjectID", TypeBool, Offset(mCompareToObjectID, GuiTreeViewCtrl));
@ -1794,6 +1814,7 @@ bool GuiTreeViewCtrl::onAdd()
mShowClassNames = false;
mShowObjectNames = false;
mShowInternalNames = true;
mShowTypeHints = false;
}
const char* objectNamesOnly = getDataField( sObjectNamesOnly, NULL );
@ -1803,6 +1824,7 @@ bool GuiTreeViewCtrl::onAdd()
mShowClassNames = false;
mShowObjectNames = true;
mShowInternalNames = false;
mShowTypeHints = false;
}
}
@ -4109,6 +4131,10 @@ GuiTreeViewCtrl::Item* GuiTreeViewCtrl::addInspectorDataItem(Item *parent, SimOb
item->mState.clear( Item::ShowInternalName );
else
item->mState.set( Item::ShowInternalName );
if (!mShowTypeHints)
item->mState.clear(Item::ShowTypeHint);
else
item->mState.set(Item::ShowTypeHint);
if( mShowClassNameForUnnamedObjects )
item->mState.set( Item::ShowClassNameForUnnamed );

View file

@ -79,6 +79,7 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
ForceItemName = BIT(15),
ForceDragTarget = BIT(16),
DenyDrag = BIT(17),
ShowTypeHint = BIT(18),
};
GuiTreeViewCtrl* mParentControl;
@ -395,6 +396,9 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
/// If true, internal names will be included in inspector tree item labels.
bool mShowInternalNames;
/// If true, TypeHints will be included in inspector tree item labels.
bool mShowTypeHints;
/// If true, class names will be used as object names for unnamed objects.
bool mShowClassNameForUnnamedObjects;

View file

@ -33,7 +33,7 @@ bool PopupMenu::smSelectionEventHandled = false;
/// Event class used to remove popup menus from the event notification in a safe way
class PopUpNotifyRemoveEvent : public SimEvent
{
{
public:
void process(SimObject *object)
{
@ -46,7 +46,7 @@ public:
//-----------------------------------------------------------------------------
PopupMenu::PopupMenu()
{
mMenuItems = NULL;
mMenuItems = 0;
mMenuBarCtrl = nullptr;
mBarTitle = StringTable->EmptyString();
@ -115,7 +115,7 @@ void PopupMenu::onMenuSelect()
//-----------------------------------------------------------------------------
void PopupMenu::handleSelectEvent(U32 popID, U32 command)
{
{
}
//-----------------------------------------------------------------------------
@ -199,7 +199,7 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
{
mMenuItems[i].mID = pos;
mMenuItems[i].mCMD = cmd;
if (accelerator && accelerator[0])
mMenuItems[i].mAccelerator = dStrdup(accelerator);
else
@ -207,7 +207,7 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
return true;
}
}
return false;
}

View file

@ -353,6 +353,17 @@ DefineEngineFunction( mLerp, F32, ( F32 v1, F32 v2, F32 time ),,
return mLerp( v1, v2, time );
}
DefineEngineFunction(mInvLerp, F32, (F32 v1, F32 v2, F32 point), ,
"Calculate the percentage of a point along a line.\n"
"@param v1 Interpolate From Input value."
"@param v2 Interpolate To Input value."
"@param point Point along range."
"@returns normalized time used to interpolate values"
"@ingroup Math")
{
return mInvLerp(v1, v2, point);
}
DefineEngineFunction( mPi, F32, (),,
"Return the value of PI (half-circle in radians).\n"
"@returns The value of PI."

View file

@ -265,6 +265,14 @@ inline T mLerp( const T &v1, const T &v2, F32 factor )
return ( v1 * ( 1.0f - factor ) ) + ( v2 * factor );
}
/// Template function for determining a percentage of interpolation between any two
/// types which implement operators for scalar multiply and addition.
template <typename T>
inline T mInvLerp(const T& v1, const T& v2, F32 point)
{
return (point - v1) / (v2 - v1);
}
inline S32 mMulDiv(S32 a, S32 b, S32 c)
{
return m_mulDivS32(a, b, c);

View file

@ -191,7 +191,7 @@ EulerF MatrixF::toEuler() const
void MatrixF::dumpMatrix(const char *caption /* =NULL */) const
{
U32 size = dStrlen(caption);
U32 size = (caption == NULL)? 0 : dStrlen(caption);
FrameTemp<char> spacer(size+1);
char *spacerRef = spacer;

View file

@ -20,7 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef __APPLE__
#if !defined( __APPLE__ ) && !defined( __FreeBSD__ )
#include <fstream>
#include <iostream>
@ -38,14 +38,18 @@
Platform::SystemInfo_struct Platform::SystemInfo;
static inline void rtrim(std::string &s)
{
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
// trim from start (in place)
static inline void ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
}));
}
static inline void ltrim(std::string &s)
{
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
// trim from end (in place)
static inline void rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
return !std::isspace(ch);
}).base(), s.end());
}
static void getCPUInformation()
@ -183,7 +187,7 @@ static void getCPUInformation()
SetProcessorInfo(Platform::SystemInfo.processor, vendorString.c_str(), brandString.c_str());
}
void Processor::init()
void Processor::init()
{
getCPUInformation();
@ -244,11 +248,11 @@ namespace CPUInfo
}
else if (!Platform::SystemInfo.processor.isHyperThreaded && Platform::SystemInfo.processor.numPhysicalProcessors == 1)
{
return CONFIG_SingleCoreAndHTNotCapable;
return CONFIG_SingleCoreAndHTNotCapable;
}
return CONFIG_MultiCoreAndHTEnabled;
}
}; // namespace CPUInfo
#endif
#endif

View file

@ -34,6 +34,7 @@
#include <unistd.h>
#include <signal.h>
#include "console/engineAPI.h"
#include "core/util/journal/process.h"
#ifndef TORQUE_DEDICATED
#include <SDL.h>
#endif
@ -48,7 +49,7 @@ static void CheckExitCode(S64 exitCode)
{
if (exitCode != 0)
{
Con::errorf(ConsoleLogEntry::General,
Con::errorf(ConsoleLogEntry::General,
"Nonzero exit code: %d, triggering SIGSEGV for core dump",
exitCode);
kill(getpid(), SIGSEGV);
@ -62,7 +63,7 @@ static void SignalHandler(int sigtype)
{
signal(SIGSEGV, SIG_DFL);
signal(SIGTRAP, SIG_DFL);
// restore the signal handling to default so that we don't get into
// restore the signal handling to default so that we don't get into
// a crash loop with ImmediateShutdown
ImmediateShutdown(-sigtype, sigtype);
}
@ -85,7 +86,7 @@ void Cleanup(bool minimal)
StdConsole::destroy();
#ifndef TORQUE_DEDICATED
#ifndef TORQUE_DEDICATED
SDL_Quit();
#endif
}
@ -105,7 +106,7 @@ void ImmediateShutdown(S32 exitCode, S32 signalNum)
}
else
{
// there is a problem in kernel 2.4.17 which causes a hang when a segfault
// there is a problem in kernel 2.4.17 which causes a hang when a segfault
// occurs. also subsequent runs of "ps" will hang and the machine has to be
// hard reset to clear up the problem
// JMQ: this bug appears to be fixed in 2.4.18
@ -130,7 +131,7 @@ void ProcessControlInit()
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
// we're not interested in the exit status of child processes, so this
// we're not interested in the exit status of child processes, so this
// prevents zombies from accumulating.
#if defined(__FreeBSD__) || defined(__APPLE__)
signal(SIGCHLD, SIG_IGN);
@ -147,6 +148,7 @@ void ProcessControlInit()
//-----------------------------------------------------------------------------
void Platform::postQuitMessage(const S32 in_quitVal)
{
// if we have a window send a quit event, otherwise just force shutdown
#if 0
if (x86UNIXState->windowCreated())
@ -155,18 +157,19 @@ void Platform::postQuitMessage(const S32 in_quitVal)
SendQuitEvent();
}
else
#endif
{
forceShutdown(in_quitVal);
}
#endif
Process::requestShutdown();
}
//-----------------------------------------------------------------------------
void Platform::debugBreak()
{
// in windows, "Calling DebugBreak causes the program to display
// in windows, "Calling DebugBreak causes the program to display
// a dialog box as if it had crashed." So we segfault.
Con::errorf(ConsoleLogEntry::General,
Con::errorf(ConsoleLogEntry::General,
"Platform::debugBreak: triggering SIGSEGV for core dump");
//kill(getpid(), SIGSEGV);
@ -197,20 +200,20 @@ void Platform::forceShutdown(S32 returnValue)
void Platform::outputDebugString(const char *string, ...)
{
char buffer[2048];
va_list args;
va_start( args, string );
dVsprintf( buffer, sizeof(buffer), string, args );
va_end( args );
U32 length = dStrlen(buffer);
if( length == (sizeof(buffer) - 1 ) )
length--;
buffer[length++] = '\n';
buffer[length] = '\0';
fwrite(buffer, sizeof(char), length, stderr);
}
@ -234,4 +237,4 @@ void Platform::restartInstance()
*/
exit(0);
}
#endif
#endif

View file

@ -0,0 +1,148 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// XXTH used for FreeBSD
// Note: SDL_cpuinfo have not all information, but better than using
// "sysctl hw"
//
//-----------------------------------------------------------------------------
#if defined( __FreeBSD__ )
#include "SDL.h"
#include "platform/platformCPUCount.h"
#include "console/console.h"
#include <math/mMathFn.h>
Platform::SystemInfo_struct Platform::SystemInfo;
void Processor::init()
{
S32 lCpuCount = SDL_GetCPUCount();
Platform::SystemInfo.processor.numLogicalProcessors = lCpuCount;
//sdl dont have logical/physical CPU count so ... time to guess
if (lCpuCount > 1)
{
Platform::SystemInfo.processor.numPhysicalProcessors = mFloor(lCpuCount / 2); // guessing ;
Platform::SystemInfo.processor.isMultiCore = true;
//modern CPU should have isHyperThreaded
Platform::SystemInfo.processor.isHyperThreaded = true;
}
else {
Platform::SystemInfo.processor.numPhysicalProcessors = lCpuCount; // guessing ;
Platform::SystemInfo.processor.isMultiCore = false;
Platform::SystemInfo.processor.isHyperThreaded = false;
}
//hackfest
Platform::SystemInfo.processor.mhz = 2666;
#if defined(TORQUE_CPU_X64) || defined(TORQUE_CPU_X32)
// Set sane default information
Platform::SystemInfo.processor.name = StringTable->insert("Unknown Processor");
Platform::SystemInfo.processor.properties |= CPU_PROP_C | CPU_PROP_FPU | CPU_PROP_LE ;
Platform::SystemInfo.processor.type = CPU_X86Compatible;
#elif defined(TORQUE_CPU_ARM32) || defined(TORQUE_CPU_ARM64)
Platform::SystemInfo.processor.type = CPU_ArmCompatible;
Platform::SystemInfo.processor.name = StringTable->insert("Unknown ARM Processor");
Platform::SystemInfo.processor.properties = CPU_PROP_C;
#else
#warning Unsupported CPU
#endif
// Set 64bit flag
#if defined(TORQUE_CPU_X64) || defined(TORQUE_CPU_ARM64)
Platform::SystemInfo.processor.properties |= CPU_PROP_64bit;
#endif
Con::printf("Processor Init:");
Con::printf(" CPU count: %d", lCpuCount);
Con::printf(" CacheLine size: %d", SDL_GetCPUCacheLineSize());
if (lCpuCount > 1) {
Platform::SystemInfo.processor.properties |= CPU_PROP_MP;
Con::printf(" MultiCore CPU detected" );
}
Con::printf(" RAM: %d MB", SDL_GetSystemRAM());
if (SDL_HasMMX()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_MMX;
Con::printf(" MMX detected" );
}
if (SDL_HasSSE()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_SSE;
Con::printf(" SSE detected" );
}
if (SDL_HasSSE2()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_SSE2;
Con::printf(" SSE2 detected" );
}
if (SDL_HasSSE3()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_SSE3;
Con::printf(" SSE3 detected" );
}
if (SDL_HasSSE41()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_SSE4_1;
Con::printf(" SSE4.1 detected" );
}
if (SDL_HasSSE42()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_SSE4_2;
Con::printf(" SSE4.2 detected" );
}
if (SDL_HasSSE42()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_SSE4_2;
Con::printf(" SSE4.2 detected" );
}
if (SDL_HasAVX() || SDL_HasAVX2()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_AVX;
Con::printf(" AVX detected" );
}
if (SDL_HasNEON()) {
Platform::SystemInfo.processor.properties |= CPU_PROP_NEON;
Con::printf(" NEON detected" );
}
Con::printf(" ");
SetProcessorInfo(Platform::SystemInfo.processor, "Unknown", "Unknown");
}
namespace CPUInfo
{
EConfig CPUCount(U32 &logical, U32 &physical)
{
// We don't set logical or physical here because it's already been determined by this point
if (Platform::SystemInfo.processor.isHyperThreaded && Platform::SystemInfo.processor.numPhysicalProcessors == 1)
{
return CONFIG_SingleCoreHTEnabled;
}
else if (!Platform::SystemInfo.processor.isHyperThreaded && Platform::SystemInfo.processor.numPhysicalProcessors > 1)
{
return CONFIG_MultiCoreAndHTNotCapable;
}
else if (!Platform::SystemInfo.processor.isHyperThreaded && Platform::SystemInfo.processor.numPhysicalProcessors == 1)
{
return CONFIG_SingleCoreAndHTNotCapable;
}
return CONFIG_MultiCoreAndHTEnabled;
}
}; // namespace CPUInfo
#endif // defined( __FreeBSD__ )

View file

@ -65,7 +65,7 @@ class TSCallback
{
public:
virtual ~TSCallback() {}
virtual void setNodeTransform(TSShapeInstance * si, S32 nodeIndex, MatrixF & localTransform) = 0;
};
@ -114,13 +114,13 @@ class TSShapeInstance
struct ObjectInstance
{
virtual ~ObjectInstance() {}
/// this needs to be set before using an objectInstance...tells us where to
/// look for the transforms...gets set be shape instance 'setStatics' method
const Vector<MatrixF> *mTransforms;
S32 nodeIndex;
/// Gets the transform of this object
inline const MatrixF& getTransform() const
{
@ -166,8 +166,8 @@ class TSShapeInstance
/// If true this mesh is forced to be hidden
/// regardless of the animation state.
bool forceHidden;
/// The time at which this mesh
/// The time at which this mesh
/// was last rendered.
U32 mLastTime;
@ -248,7 +248,7 @@ class TSShapeInstance
static Vector<TSThread*> smTranslationThreads;
static Vector<TSThread*> smScaleThreads;
/// @}
TSMaterialList* mMaterialList; ///< by default, points to hShape material list
//-------------------------------------------------------------------------------------
// Misc.
@ -333,17 +333,17 @@ protected:
TSShape* getShape() const { return mShape; }
TSMaterialList* getMaterialList() const { return mMaterialList; }
/// Set the material list without taking ownership.
/// @see cloneMaterialList
void setMaterialList( TSMaterialList *matList );
/// Call this to own the material list -- i.e., we'll make a copy of the
/// Call this to own the material list -- i.e., we'll make a copy of the
/// currently set material list and be responsible for deleting it. You
/// can pass an optional feature set for initializing the cloned materials.
void cloneMaterialList( const FeatureSet *features = NULL );
void cloneMaterialList( const FeatureSet *features = NULL );
/// Initializes or re-initializes the material list with
/// Initializes or re-initializes the material list with
/// an optional feature set.
void initMaterialList( const FeatureSet *features = NULL );
@ -469,7 +469,7 @@ protected:
static F32 smDetailAdjust;
/// If this is set to a positive pixel value shapes
/// with a smaller pixel size than this will skip
/// with a smaller pixel size than this will skip
/// rendering entirely.
static F32 smSmallestVisiblePixelSize;
@ -490,7 +490,7 @@ protected:
void renderDebugNormals( F32 normalScalar, S32 dl );
/// Render all node transforms as small axis gizmos. It is recommended
/// that prior to calling this, shapeInstance::animate is called so that
/// that prior to calling this, shapeInstance::animate is called so that
/// nodes are in object space and that the GFX state is setup for
/// rendering in model space.
void renderDebugNodes();
@ -518,7 +518,7 @@ protected:
/// Sets the 'forceHidden' state on the named mesh.
/// @see MeshObjectInstance::forceHidden
void setMeshForceHidden( const char *meshName, bool hidden );
/// Sets the 'forceHidden' state on a mesh.
/// @see MeshObjectInstance::forceHidden
void setMeshForceHidden( S32 meshIndex, bool hidden );
@ -558,8 +558,8 @@ protected:
void setCurrentDetail( S32 dl, F32 intraDL = 1.0f );
/// Helper function which internally calls setDetailFromDistance.
S32 setDetailFromPosAndScale( const SceneRenderState *state,
const Point3F &pos,
S32 setDetailFromPosAndScale( const SceneRenderState *state,
const Point3F &pos,
const Point3F &scale );
/// Selects the current detail level using the scaled
@ -788,7 +788,7 @@ class TSThread
keyPos = 0;
mSeqPos = 0;
mShapeInstance = NULL;
makePath = NULL;
makePath = false;
priority = 0;
sequence = 0;
timeScale = 1.0f;