mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Merge remote-tracking branch 'upstream/development' into development
This commit is contained in:
commit
4fa4233ae4
19 changed files with 694 additions and 898 deletions
|
|
@ -190,12 +190,6 @@ SoundAsset::SoundAsset()
|
||||||
SoundAsset::~SoundAsset()
|
SoundAsset::~SoundAsset()
|
||||||
{
|
{
|
||||||
|
|
||||||
for (U32 i = 0; i < SFXPlayList::NUM_SLOTS; i++)
|
|
||||||
{
|
|
||||||
if(mSFXProfile[i].isProperlyAdded() && !mSFXProfile[i].isDeleted())
|
|
||||||
mSFXProfile[i].unregisterObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mPlaylist.isProperlyAdded() && !mPlaylist.isDeleted())
|
if (mPlaylist.isProperlyAdded() && !mPlaylist.isDeleted())
|
||||||
mPlaylist.unregisterObject();
|
mPlaylist.unregisterObject();
|
||||||
}
|
}
|
||||||
|
|
@ -404,22 +398,17 @@ U32 SoundAsset::load()
|
||||||
{
|
{
|
||||||
Con::errorf("SoundAsset::initializeAsset: Attempted to load file %s but it was not valid!", mSoundFile[i]);
|
Con::errorf("SoundAsset::initializeAsset: Attempted to load file %s but it was not valid!", mSoundFile[i]);
|
||||||
mLoadedState = BadFileReference;
|
mLoadedState = BadFileReference;
|
||||||
mSFXProfile[i].setDescription(NULL);
|
|
||||||
mSFXProfile[i].setSoundFileName(StringTable->insert(StringTable->EmptyString()));
|
|
||||||
mSFXProfile[i].setPreload(false);
|
|
||||||
return mLoadedState;
|
return mLoadedState;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SFXProfile* trackProfile = new SFXProfile();
|
mSFXProfile[i] = new SFXProfile;
|
||||||
trackProfile->setDescription(&mProfileDesc);
|
mSFXProfile[i]->setDescription(&mProfileDesc);
|
||||||
trackProfile->setSoundFileName(mSoundPath[i]);
|
mSFXProfile[i]->setSoundFileName(mSoundPath[i]);
|
||||||
trackProfile->setPreload(mPreload);
|
mSFXProfile[i]->setPreload(mPreload);
|
||||||
|
mSFXProfile[i]->registerObject(String::ToString("%s_profile_track%d", getAssetName()).c_str());
|
||||||
|
|
||||||
mSFXProfile[i] = *trackProfile;
|
mPlaylist.mSlots.mTrack[i] = mSFXProfile[i];
|
||||||
mSFXProfile[i].registerObject(String::ToString("%s_profile_track%d", getAssetName()).c_str());
|
|
||||||
|
|
||||||
mPlaylist.mSlots.mTrack[i] = trackProfile;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -436,18 +425,15 @@ U32 SoundAsset::load()
|
||||||
{
|
{
|
||||||
Con::errorf("SoundAsset::initializeAsset: Attempted to load file %s but it was not valid!", mSoundFile[0]);
|
Con::errorf("SoundAsset::initializeAsset: Attempted to load file %s but it was not valid!", mSoundFile[0]);
|
||||||
mLoadedState = BadFileReference;
|
mLoadedState = BadFileReference;
|
||||||
mSFXProfile[0].setDescription(NULL);
|
|
||||||
mSFXProfile[0].setSoundFileName(StringTable->insert(StringTable->EmptyString()));
|
|
||||||
mSFXProfile[0].setPreload(false);
|
|
||||||
return mLoadedState;
|
return mLoadedState;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mSFXProfile[0].setDescription(&mProfileDesc);
|
mSFXProfile[0] = new SFXProfile;
|
||||||
mSFXProfile[0].setSoundFileName(mSoundPath[0]);
|
mSFXProfile[0]->setDescription(&mProfileDesc);
|
||||||
mSFXProfile[0].setPreload(mPreload);
|
mSFXProfile[0]->setSoundFileName(mSoundPath[0]);
|
||||||
|
mSFXProfile[0]->setPreload(mPreload);
|
||||||
mSFXProfile[0].registerObject(String::ToString("%s_profile", getAssetName()).c_str());
|
mSFXProfile[0]->registerObject(String::ToString("%s_profile", getAssetName()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,9 @@ class SoundAsset : public AssetBase
|
||||||
typedef AssetPtr<SoundAsset> ConcreteAssetPtr;
|
typedef AssetPtr<SoundAsset> ConcreteAssetPtr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StringTableEntry mSoundFile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
StringTableEntry mSoundFile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
StringTableEntry mSoundPath[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
StringTableEntry mSoundPath[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
SFXProfile mSFXProfile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
SimObjectPtr<SFXProfile> mSFXProfile[SFXPlayList::SFXPlaylistSettings::NUM_SLOTS];
|
||||||
|
|
||||||
SFXDescription mProfileDesc;
|
SFXDescription mProfileDesc;
|
||||||
SFXPlayList mPlaylist;
|
SFXPlayList mPlaylist;
|
||||||
|
|
@ -150,7 +150,7 @@ public:
|
||||||
void copyTo(SimObject* object) override;
|
void copyTo(SimObject* object) override;
|
||||||
|
|
||||||
//SFXResource* getSound() { return mSoundResource; }
|
//SFXResource* getSound() { return mSoundResource; }
|
||||||
Resource<SFXResource> getSoundResource(const U32 slotId = 0) { load(); return mSFXProfile[slotId].getResource(); }
|
Resource<SFXResource> getSoundResource(const U32 slotId = 0) { load(); return mSFXProfile[slotId]->getResource(); }
|
||||||
|
|
||||||
/// Declare Console Object.
|
/// Declare Console Object.
|
||||||
DECLARE_CONOBJECT(SoundAsset);
|
DECLARE_CONOBJECT(SoundAsset);
|
||||||
|
|
@ -158,9 +158,9 @@ public:
|
||||||
static bool _setSoundFile(void* object, const char* index, const char* data);
|
static bool _setSoundFile(void* object, const char* index, const char* data);
|
||||||
U32 load() override;
|
U32 load() override;
|
||||||
inline StringTableEntry getSoundPath(const U32 slotId = 0) const { return mSoundPath[slotId]; };
|
inline StringTableEntry getSoundPath(const U32 slotId = 0) const { return mSoundPath[slotId]; };
|
||||||
SFXProfile* getSfxProfile(const U32 slotId = 0) { return &mSFXProfile[slotId]; }
|
SFXProfile* getSfxProfile(const U32 slotId = 0) { return mSFXProfile[slotId]; }
|
||||||
SFXPlayList* getSfxPlaylist() { return &mPlaylist; }
|
SFXPlayList* getSfxPlaylist() { return &mPlaylist; }
|
||||||
SFXTrack* getSFXTrack() { load(); return mIsPlaylist ? dynamic_cast<SFXTrack*>(&mPlaylist) : dynamic_cast<SFXTrack*>(&mSFXProfile[0]); }
|
SFXTrack* getSFXTrack() { load(); return mIsPlaylist ? dynamic_cast<SFXTrack*>(&mPlaylist) : dynamic_cast<SFXTrack*>(mSFXProfile[0].getPointer()); }
|
||||||
SFXDescription* getSfxDescription() { return &mProfileDesc; }
|
SFXDescription* getSfxDescription() { return &mProfileDesc; }
|
||||||
bool isPlaylist(){ return mIsPlaylist; }
|
bool isPlaylist(){ return mIsPlaylist; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -471,6 +471,7 @@ bool PlayerData::preload(bool server, String &errorStr)
|
||||||
if (!server) {
|
if (!server) {
|
||||||
for (U32 i = 0; i < MaxSounds; ++i)
|
for (U32 i = 0; i < MaxSounds; ++i)
|
||||||
{
|
{
|
||||||
|
_setPlayerSound(getPlayerSound(i), i);
|
||||||
if (!isPlayerSoundValid(i))
|
if (!isPlayerSoundValid(i))
|
||||||
{
|
{
|
||||||
//return false; -TODO: trigger asset download
|
//return false; -TODO: trigger asset download
|
||||||
|
|
|
||||||
|
|
@ -348,6 +348,7 @@ bool RigidShapeData::preload(bool server, String &errorStr)
|
||||||
if (!server) {
|
if (!server) {
|
||||||
for (S32 i = 0; i < Body::MaxSounds; i++)
|
for (S32 i = 0; i < Body::MaxSounds; i++)
|
||||||
{
|
{
|
||||||
|
_setBodySounds(getBodySounds(i), i);
|
||||||
if (!isBodySoundsValid(i))
|
if (!isBodySoundsValid(i))
|
||||||
{
|
{
|
||||||
//return false; -TODO: trigger asset download
|
//return false; -TODO: trigger asset download
|
||||||
|
|
@ -356,6 +357,7 @@ bool RigidShapeData::preload(bool server, String &errorStr)
|
||||||
|
|
||||||
for (S32 j = 0; j < Sounds::MaxSounds; j++)
|
for (S32 j = 0; j < Sounds::MaxSounds; j++)
|
||||||
{
|
{
|
||||||
|
_setWaterSounds(getWaterSounds(j), j);
|
||||||
if (!isWaterSoundsValid(j))
|
if (!isWaterSoundsValid(j))
|
||||||
{
|
{
|
||||||
//return false; -TODO: trigger asset download
|
//return false; -TODO: trigger asset download
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ bool FlyingVehicleData::preload(bool server, String &errorStr)
|
||||||
if (!server) {
|
if (!server) {
|
||||||
for (S32 i = 0; i < MaxSounds; i++)
|
for (S32 i = 0; i < MaxSounds; i++)
|
||||||
{
|
{
|
||||||
|
_setFlyingSounds(getFlyingSounds(i), i);
|
||||||
if (!isFlyingSoundsValid(i))
|
if (!isFlyingSoundsValid(i))
|
||||||
{
|
{
|
||||||
//return false; -TODO: trigger asset download
|
//return false; -TODO: trigger asset download
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,7 @@ bool HoverVehicleData::preload(bool server, String &errorStr)
|
||||||
|
|
||||||
for (S32 i = 0; i < MaxSounds; i++)
|
for (S32 i = 0; i < MaxSounds; i++)
|
||||||
{
|
{
|
||||||
|
_setHoverSounds(getHoverSounds(i), i);
|
||||||
if (!isHoverSoundsValid(i))
|
if (!isHoverSoundsValid(i))
|
||||||
{
|
{
|
||||||
//return false; -TODO: trigger asset download
|
//return false; -TODO: trigger asset download
|
||||||
|
|
|
||||||
|
|
@ -348,6 +348,7 @@ bool WheeledVehicleData::preload(bool server, String &errorStr)
|
||||||
if (!server) {
|
if (!server) {
|
||||||
for (S32 i = 0; i < MaxSounds; i++)
|
for (S32 i = 0; i < MaxSounds; i++)
|
||||||
{
|
{
|
||||||
|
_setWheeledVehicleSounds(getWheeledVehicleSounds(i), i);
|
||||||
if (!isWheeledVehicleSoundsValid(i))
|
if (!isWheeledVehicleSoundsValid(i))
|
||||||
{
|
{
|
||||||
//return false; -TODO: trigger asset download
|
//return false; -TODO: trigger asset download
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,10 @@
|
||||||
#ifndef _TAML_CALLBACKS_H_
|
#ifndef _TAML_CALLBACKS_H_
|
||||||
#include "persistence/taml/tamlCallbacks.h"
|
#include "persistence/taml/tamlCallbacks.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _OBJECTTYPES_H_
|
||||||
#include "T3D/objectTypes.h"
|
#include "T3D/objectTypes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class Stream;
|
class Stream;
|
||||||
class LightManager;
|
class LightManager;
|
||||||
|
|
@ -606,6 +609,7 @@ class SimObject: public ConsoleObject, public TamlCallbacks
|
||||||
|
|
||||||
/// @name Events
|
/// @name Events
|
||||||
/// @{
|
/// @{
|
||||||
|
//virtual void onPrepare();
|
||||||
|
|
||||||
/// Called when the object is added to the sim.
|
/// Called when the object is added to the sim.
|
||||||
virtual bool onAdd();
|
virtual bool onAdd();
|
||||||
|
|
@ -1045,56 +1049,47 @@ DefineBitfieldType(GameTypeMasksType);
|
||||||
template< typename T >
|
template< typename T >
|
||||||
class SimObjectPtr : public WeakRefPtr< T >
|
class SimObjectPtr : public WeakRefPtr< T >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef WeakRefPtr< T > Parent;
|
typedef WeakRefPtr< T > Parent;
|
||||||
|
|
||||||
SimObjectPtr() {}
|
SimObjectPtr() = default;
|
||||||
SimObjectPtr(T *ptr) { this->mReference = NULL; set(ptr); }
|
SimObjectPtr(T* ptr) { set(ptr); }
|
||||||
SimObjectPtr( const SimObjectPtr& ref ) { this->mReference = NULL; set(ref.mReference); }
|
SimObjectPtr(const SimObjectPtr&) = default;
|
||||||
|
SimObjectPtr& operator=(const SimObjectPtr&) = default;
|
||||||
|
SimObjectPtr& operator=(T* ptr)
|
||||||
|
{
|
||||||
|
set(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
T* getObject() const { return Parent::getPointer(); }
|
T* getObject() const { return Parent::getPointer(); }
|
||||||
|
|
||||||
~SimObjectPtr() { set((WeakRefBase::WeakReference*)NULL); }
|
protected:
|
||||||
|
void set(T* obj)
|
||||||
|
{
|
||||||
|
// Nothing to do if same object
|
||||||
|
if (obj && this->mWeak.lock() == obj->getWeakControl().lock())
|
||||||
|
return;
|
||||||
|
|
||||||
SimObjectPtr<T>& operator=(const SimObjectPtr ref)
|
// Before overwriting, check old object for auto-delete
|
||||||
|
if (auto old_ctrl = this->mWeak.lock())
|
||||||
{
|
{
|
||||||
set(ref.mReference);
|
T* old_obj = getObject();
|
||||||
return *this;
|
if (this->mWeak.use_count() == 1 && old_obj && old_obj->isAutoDeleted())
|
||||||
}
|
|
||||||
SimObjectPtr<T>& operator=(T *ptr)
|
|
||||||
{
|
|
||||||
set(ptr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void set(WeakRefBase::WeakReference * ref)
|
|
||||||
{
|
|
||||||
if( ref == this->mReference )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( this->mReference )
|
|
||||||
{
|
{
|
||||||
// Auto-delete
|
old_obj->destroySelf();
|
||||||
T* obj = this->getPointer();
|
|
||||||
if ( this->mReference->getRefCount() == 2 && obj && obj->isAutoDeleted() )
|
|
||||||
obj->deleteObject();
|
|
||||||
|
|
||||||
this->mReference->decRefCount();
|
|
||||||
}
|
|
||||||
this->mReference = NULL;
|
|
||||||
if( ref )
|
|
||||||
{
|
|
||||||
this->mReference = ref;
|
|
||||||
this->mReference->incRefCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set(T * obj)
|
// Assign new weak reference
|
||||||
|
this->mWeak.reset();
|
||||||
|
if (obj)
|
||||||
{
|
{
|
||||||
set(obj ? obj->getWeakReference() : (WeakRefBase::WeakReference *)NULL);
|
auto obj_ctrl = obj->getWeakControl().lock();
|
||||||
|
this->mWeak = obj_ctrl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SIMOBJECT_H_
|
#endif // _SIMOBJECT_H_
|
||||||
|
|
|
||||||
18
Engine/source/core/util/refBase.cpp
Normal file
18
Engine/source/core/util/refBase.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "refBase.h"
|
||||||
|
|
||||||
|
WeakRefBase::~WeakRefBase()
|
||||||
|
{
|
||||||
|
if (mControl)
|
||||||
|
mControl->object = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WeakControlBlock::WeakControlBlock(WeakRefBase* obj)
|
||||||
|
: object(obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
WeakControlBlock::~WeakControlBlock()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -30,52 +30,52 @@
|
||||||
# include "platform/typetraits.h"
|
# include "platform/typetraits.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
class WeakRefBase;
|
||||||
|
|
||||||
|
struct WeakControlBlock
|
||||||
|
{
|
||||||
|
explicit WeakControlBlock(WeakRefBase* obj);
|
||||||
|
~WeakControlBlock();
|
||||||
|
|
||||||
|
WeakRefBase* object;
|
||||||
|
};
|
||||||
|
|
||||||
/// Base class for objects which can be weakly referenced
|
/// Base class for objects which can be weakly referenced
|
||||||
/// (i.e., reference goes away when object is destroyed).
|
/// (i.e., reference goes away when object is destroyed).
|
||||||
class WeakRefBase
|
class WeakRefBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
WeakRefBase()
|
||||||
/// Weak reference to WeakRefBase.
|
: mControl(std::make_shared<WeakControlBlock>(this))
|
||||||
class WeakReference
|
|
||||||
{
|
{
|
||||||
public:
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr WeakRefBase* get() const { return mObject; }
|
virtual ~WeakRefBase();
|
||||||
[[nodiscard]] constexpr U32 getRefCount() const { return mRefCount; }
|
|
||||||
|
|
||||||
constexpr void incRefCount() { mRefCount++; }
|
// Copy constructor
|
||||||
constexpr void decRefCount() {
|
WeakRefBase(const WeakRefBase&) = delete;
|
||||||
AssertFatal( mRefCount > 0, "WeakReference - decrementing count of zero!" );
|
WeakRefBase& operator=(const WeakRefBase&) = delete;
|
||||||
if (--mRefCount==0)
|
WeakRefBase(WeakRefBase&&) = delete;
|
||||||
delete this;
|
WeakRefBase& operator=(WeakRefBase&&) = delete;
|
||||||
}
|
|
||||||
private:
|
|
||||||
|
|
||||||
friend class WeakRefBase;
|
std::weak_ptr<WeakControlBlock> getWeakControl()
|
||||||
constexpr explicit WeakReference(WeakRefBase *object) :mObject(object), mRefCount(0) {}
|
{
|
||||||
|
return mControl;
|
||||||
|
}
|
||||||
|
|
||||||
~WeakReference() { AssertFatal(mObject==NULL, "Deleting weak reference which still points at an object."); }
|
std::shared_ptr<WeakControlBlock> getSharedControl()
|
||||||
|
{
|
||||||
// Object we reference
|
return mControl;
|
||||||
WeakRefBase *mObject;
|
}
|
||||||
|
|
||||||
// reference count for this structure (not WeakObjectRef itself)
|
|
||||||
U32 mRefCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
constexpr WeakRefBase() : mReference(NULL) {}
|
|
||||||
virtual ~WeakRefBase() { clearWeakReferences(); }
|
|
||||||
|
|
||||||
WeakReference* getWeakReference();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void clearWeakReferences();
|
|
||||||
|
|
||||||
|
std::shared_ptr<WeakControlBlock> mControl;
|
||||||
private:
|
private:
|
||||||
WeakReference * mReference;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T > class SimObjectPtr;
|
template< typename T > class SimObjectPtr;
|
||||||
|
|
@ -88,100 +88,48 @@ template< typename T > class SimObjectPtr;
|
||||||
template <class T> class WeakRefPtr
|
template <class T> class WeakRefPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
constexpr WeakRefPtr() : mReference(NULL) {}
|
WeakRefPtr() = default;
|
||||||
WeakRefPtr(T *ptr) : mReference(NULL) { set(ptr); }
|
WeakRefPtr(T* obj) { set(obj); }
|
||||||
WeakRefPtr(const WeakRefPtr<T> & ref) { mReference = NULL; set(ref.mReference); }
|
|
||||||
|
|
||||||
~WeakRefPtr() { set(static_cast<WeakRefBase::WeakReference *>(NULL)); }
|
WeakRefPtr(const WeakRefPtr&) = default;
|
||||||
|
WeakRefPtr& operator=(const WeakRefPtr&) = default;
|
||||||
|
|
||||||
WeakRefPtr<T>& operator=(const WeakRefPtr<T>& ref)
|
WeakRefPtr& operator=(T* obj)
|
||||||
{
|
{
|
||||||
if (this == &ref) { return *this; } // handle self assignment ( x = x; )
|
set(obj);
|
||||||
set(ref.mReference);
|
return *this;
|
||||||
return *this;
|
}
|
||||||
}
|
|
||||||
WeakRefPtr<T>& operator=(T *ptr)
|
|
||||||
{
|
|
||||||
set(ptr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if the pointer is not set.
|
bool isValid() const { return getPointer() != NULL; }
|
||||||
[[nodiscard]] constexpr bool isNull() const { return mReference == NULL || mReference->get() == NULL; }
|
bool isNull() const { return getPointer() == NULL; }
|
||||||
|
|
||||||
/// Returns true if the pointer is set.
|
|
||||||
[[nodiscard]] constexpr bool isValid() const { return mReference && mReference->get(); }
|
|
||||||
|
|
||||||
[[nodiscard]] constexpr T* operator->() const { return getPointer(); }
|
[[nodiscard]] constexpr T* operator->() const { return getPointer(); }
|
||||||
[[nodiscard]] constexpr T& operator*() const { return *getPointer(); }
|
[[nodiscard]] constexpr T& operator*() const { return *getPointer(); }
|
||||||
[[nodiscard]] constexpr operator T*() const { return getPointer(); }
|
[[nodiscard]] constexpr operator T*() const { return getPointer(); }
|
||||||
|
|
||||||
/// Returns the pointer.
|
/// Returns the pointer.
|
||||||
[[nodiscard]] constexpr T* getPointer() const { return mReference ? (T*)mReference->get() : NULL; }
|
[[nodiscard]] constexpr T* getPointer() const
|
||||||
|
{
|
||||||
|
auto ctrl = mWeak.lock();
|
||||||
|
if (!ctrl || !ctrl->object)
|
||||||
|
return NULL;
|
||||||
|
return (T*)(ctrl->object);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void set(WeakRefBase::WeakReference* ref)
|
void set(T* obj)
|
||||||
{
|
{
|
||||||
if (mReference)
|
if (!obj)
|
||||||
mReference->decRefCount();
|
|
||||||
mReference = NULL;
|
|
||||||
if (ref)
|
|
||||||
{
|
{
|
||||||
mReference = ref;
|
mWeak.reset();
|
||||||
mReference->incRefCount();
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void set(T* obj) { set(obj ? obj->getWeakReference() : NULL); }
|
mWeak = obj->getWeakControl();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
template< typename > friend class SimObjectPtr;
|
template< typename > friend class SimObjectPtr;
|
||||||
WeakRefBase::WeakReference * mReference {NULL};
|
std::weak_ptr<WeakControlBlock> mWeak;
|
||||||
};
|
|
||||||
|
|
||||||
/// Union of an arbitrary type with a WeakRefBase. The exposed type will
|
|
||||||
/// remain accessible so long as the WeakRefBase is not cleared. Once
|
|
||||||
/// it is cleared, accessing the exposed type will result in a NULL pointer.
|
|
||||||
template<class ExposedType>
|
|
||||||
class WeakRefUnion
|
|
||||||
{
|
|
||||||
typedef WeakRefUnion<ExposedType> Union;
|
|
||||||
|
|
||||||
public:
|
|
||||||
constexpr WeakRefUnion() : mPtr(NULL) {}
|
|
||||||
constexpr WeakRefUnion(const WeakRefPtr<WeakRefBase> & ref, ExposedType * ptr) : mPtr(NULL) { set(ref, ptr); }
|
|
||||||
constexpr WeakRefUnion(const Union & lock) : mPtr(NULL) { *this = lock; }
|
|
||||||
constexpr WeakRefUnion(WeakRefBase * ref) : mPtr(NULL) { set(ref, dynamic_cast<ExposedType*>(ref)); }
|
|
||||||
~WeakRefUnion() { mWeakReference = NULL; }
|
|
||||||
|
|
||||||
Union & operator=(const Union & ptr)
|
|
||||||
{
|
|
||||||
if (this == *ptr) { return *this; }
|
|
||||||
set(ptr.mWeakReference, ptr.getPointer());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(const WeakRefPtr<WeakRefBase> & ref, ExposedType * ptr)
|
|
||||||
{
|
|
||||||
mWeakReference = ref;
|
|
||||||
mPtr = ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool operator == (const ExposedType * t ) const { return getPointer() == t; }
|
|
||||||
[[nodiscard]] constexpr bool operator != (const ExposedType * t ) const { return getPointer() != t; }
|
|
||||||
[[nodiscard]] constexpr bool operator == (const Union &t ) const { return getPointer() == t.getPointer(); }
|
|
||||||
[[nodiscard]] constexpr bool operator != (const Union &t ) const { return getPointer() != t.getPointer(); }
|
|
||||||
[[nodiscard]] constexpr bool isNull() const { return mWeakReference.isNull() || !mPtr; }
|
|
||||||
|
|
||||||
[[nodiscard]] constexpr ExposedType* getPointer() const { return !mWeakReference.isNull() ? mPtr : NULL; }
|
|
||||||
[[nodiscard]] constexpr ExposedType* operator->() const { return getPointer(); }
|
|
||||||
[[nodiscard]] constexpr ExposedType& operator*() const { return *getPointer(); }
|
|
||||||
[[nodiscard]] constexpr operator ExposedType*() const { return getPointer(); }
|
|
||||||
|
|
||||||
[[nodiscard]] WeakRefPtr<WeakRefBase> getRef() const { return mWeakReference; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
WeakRefPtr<WeakRefBase> mWeakReference;
|
|
||||||
ExposedType * mPtr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Base class for objects which can be strongly referenced
|
/// Base class for objects which can be strongly referenced
|
||||||
|
|
@ -189,34 +137,40 @@ private:
|
||||||
/// when all strong references go away, object is destroyed).
|
/// when all strong references go away, object is destroyed).
|
||||||
class StrongRefBase : public WeakRefBase
|
class StrongRefBase : public WeakRefBase
|
||||||
{
|
{
|
||||||
friend class StrongObjectRef;
|
friend class StrongObjectRef;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StrongRefBase() { mRefCount = 0; }
|
StrongRefBase()
|
||||||
|
{
|
||||||
|
mRefCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
U32 getRefCount() const { return mRefCount; }
|
virtual ~StrongRefBase() = default;
|
||||||
|
|
||||||
/// object destroy self call (from StrongRefPtr). Override if this class has specially allocated memory.
|
U32 getRefCount() const { return mRefCount; }
|
||||||
virtual void destroySelf() { delete this; }
|
|
||||||
|
|
||||||
/// Increments the reference count.
|
/// object destroy self call (from StrongRefPtr). Override if this class has specially allocated memory.
|
||||||
void incRefCount()
|
virtual void destroySelf() { delete this; }
|
||||||
{
|
|
||||||
mRefCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Decrements the reference count.
|
/// Increments the reference count.
|
||||||
void decRefCount()
|
void incRefCount()
|
||||||
{
|
{
|
||||||
AssertFatal(mRefCount, "Decrementing a reference with refcount 0!");
|
mRefCount++;
|
||||||
if(!--mRefCount)
|
}
|
||||||
destroySelf();
|
|
||||||
}
|
/// Decrements the reference count.
|
||||||
|
void decRefCount()
|
||||||
|
{
|
||||||
|
AssertFatal(mRefCount, "Decrementing a reference with refcount 0!");
|
||||||
|
if (!--mRefCount)
|
||||||
|
destroySelf();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
U32 mRefCount; ///< reference counter for StrongRefPtr objects
|
U32 mRefCount; ///< reference counter for StrongRefPtr objects
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Base class for StrongRefBase strong reference pointers.
|
/// Base class for StrongRefBase strong reference pointers.
|
||||||
class StrongObjectRef
|
class StrongObjectRef
|
||||||
{
|
{
|
||||||
|
|
@ -289,55 +243,6 @@ public:
|
||||||
T* getPointer() const { return const_cast<T*>(static_cast<T* const>(mObject)); }
|
T* getPointer() const { return const_cast<T*>(static_cast<T* const>(mObject)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Union of an arbitrary type with a StrongRefBase. StrongRefBase will remain locked
|
|
||||||
/// until the union is destructed. Handy for when the exposed class will
|
|
||||||
/// become invalid whenever the reference becomes invalid and you want to make sure that doesn't
|
|
||||||
/// happen.
|
|
||||||
template<class ExposedType>
|
|
||||||
class StrongRefUnion
|
|
||||||
{
|
|
||||||
typedef StrongRefUnion<ExposedType> Union;
|
|
||||||
|
|
||||||
public:
|
|
||||||
StrongRefUnion() : mPtr(NULL) {}
|
|
||||||
|
|
||||||
StrongRefUnion(const StrongRefPtr<StrongRefBase> & ref, ExposedType * ptr) : mPtr(NULL) { set(ref, ptr); }
|
|
||||||
StrongRefUnion(const Union & lock) : mPtr(NULL) { *this = lock; }
|
|
||||||
StrongRefUnion(StrongRefBase * ref) : mPtr(NULL) { set(ref, dynamic_cast<ExposedType*>(ref)); }
|
|
||||||
|
|
||||||
~StrongRefUnion() { mReference = NULL; }
|
|
||||||
|
|
||||||
Union & operator=(const Union & ptr)
|
|
||||||
{
|
|
||||||
set(ptr.mReference, ptr.mPtr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(const StrongRefPtr<StrongRefBase> & ref, ExposedType * ptr)
|
|
||||||
{
|
|
||||||
mReference = ref;
|
|
||||||
mPtr = ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool operator == (const ExposedType * t ) const { return mPtr == t; }
|
|
||||||
[[nodiscard]] constexpr bool operator != (const ExposedType * t ) const { return mPtr != t; }
|
|
||||||
[[nodiscard]] constexpr bool operator == (const Union &t ) const { return mPtr == t.mPtr; }
|
|
||||||
[[nodiscard]] constexpr bool operator != (const Union &t ) const { return mPtr != t.mPtr; }
|
|
||||||
[[nodiscard]] constexpr bool isNull() const { return mReference.isNull() || !mPtr; }
|
|
||||||
[[nodiscard]] constexpr bool isValid() const { return mReference.isValid() && mPtr; }
|
|
||||||
|
|
||||||
ExposedType* operator->() const { return mPtr; }
|
|
||||||
ExposedType& operator*() const { return *mPtr; }
|
|
||||||
operator ExposedType*() const { return mPtr; }
|
|
||||||
ExposedType* getPointer() const { return mPtr; }
|
|
||||||
|
|
||||||
StrongRefPtr<StrongRefBase> getRef() const { return mReference; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
StrongRefPtr<StrongRefBase> mReference;
|
|
||||||
ExposedType * mPtr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// This oxymoron is a pointer that reference-counts the referenced
|
/// This oxymoron is a pointer that reference-counts the referenced
|
||||||
/// object but also NULLs out if the object goes away.
|
/// object but also NULLs out if the object goes away.
|
||||||
///
|
///
|
||||||
|
|
@ -347,97 +252,91 @@ private:
|
||||||
/// StrongWeakRefs that keep object live as long as the superior entity doesn't
|
/// StrongWeakRefs that keep object live as long as the superior entity doesn't
|
||||||
/// step in and kill them (in which case, the client code sees the reference
|
/// step in and kill them (in which case, the client code sees the reference
|
||||||
/// disappear).
|
/// disappear).
|
||||||
template< class T >
|
template<class T>
|
||||||
class StrongWeakRefPtr
|
class StrongWeakRefPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
constexpr StrongWeakRefPtr() : mReference( NULL ) {}
|
StrongWeakRefPtr() = default;
|
||||||
constexpr StrongWeakRefPtr( T* ptr ) : mReference( NULL ) { _set( ptr ); }
|
|
||||||
~StrongWeakRefPtr()
|
|
||||||
{
|
|
||||||
if( mReference )
|
|
||||||
{
|
|
||||||
T* ptr = _get();
|
|
||||||
if( ptr )
|
|
||||||
ptr->decRefCount();
|
|
||||||
|
|
||||||
mReference->decRefCount();
|
StrongWeakRefPtr(T* ptr) { set(ptr); }
|
||||||
}
|
|
||||||
|
StrongWeakRefPtr(const StrongWeakRefPtr& other)
|
||||||
|
{
|
||||||
|
set(other.getPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool isNull() const { return ( _get() == NULL ); }
|
StrongWeakRefPtr& operator=(const StrongWeakRefPtr& other)
|
||||||
[[nodiscard]] constexpr bool operator ==( T* ptr ) const { return ( _get() == ptr ); }
|
|
||||||
[[nodiscard]] constexpr bool operator !=( T* ptr ) const { return ( _get() != ptr ); }
|
|
||||||
[[nodiscard]] constexpr bool operator !() const { return isNull(); }
|
|
||||||
[[nodiscard]] constexpr T* operator ->() const { return _get(); }
|
|
||||||
[[nodiscard]] constexpr T& operator *() const { return *( _get() ); }
|
|
||||||
|
|
||||||
constexpr operator T*() const { return _get(); } // consider making this explicit
|
|
||||||
|
|
||||||
T* getPointer() const { return _get(); }
|
|
||||||
|
|
||||||
StrongWeakRefPtr& operator =( T* ptr )
|
|
||||||
{
|
{
|
||||||
_set( ptr );
|
if (this != &other)
|
||||||
|
set(other.getPointer());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
~StrongWeakRefPtr()
|
||||||
WeakRefBase::WeakReference* mReference;
|
|
||||||
|
|
||||||
T* _get() const
|
|
||||||
{
|
{
|
||||||
if( mReference )
|
release();
|
||||||
return static_cast< T* >( mReference->get() );
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
void _set( T* ptr )
|
|
||||||
|
StrongWeakRefPtr& operator=(T* ptr)
|
||||||
|
{
|
||||||
|
set(ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValid() const { return getPointer() != NULL; }
|
||||||
|
bool isNull() const { return getPointer() == NULL; }
|
||||||
|
[[nodiscard]] bool operator==(T* ptr) const { return getPointer() == ptr; }
|
||||||
|
[[nodiscard]] bool operator!=(T* ptr) const { return getPointer() != ptr; }
|
||||||
|
[[nodiscard]] bool operator!() const { return isNull(); }
|
||||||
|
|
||||||
|
[[nodiscard]] T* operator->() const { return getPointer(); }
|
||||||
|
[[nodiscard]] T& operator*() const { return *getPointer(); }
|
||||||
|
constexpr operator T* () const { return getPointer(); }
|
||||||
|
|
||||||
|
[[nodiscard]] T* getPointer() const
|
||||||
{
|
{
|
||||||
if( mReference )
|
return mControl ? static_cast<T*>(mControl->object) : NULL;
|
||||||
{
|
}
|
||||||
T* old = _get();
|
|
||||||
if( old )
|
|
||||||
old->decRefCount();
|
|
||||||
|
|
||||||
mReference->decRefCount();
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<WeakControlBlock> mControl;
|
||||||
|
T* mPtr = NULL;
|
||||||
|
|
||||||
|
void set(T* ptr)
|
||||||
|
{
|
||||||
|
release();
|
||||||
|
if (!ptr) return;
|
||||||
|
|
||||||
|
// Always hold the identity
|
||||||
|
mControl = ptr->getWeakControl().lock();
|
||||||
|
if (!mControl) return;
|
||||||
|
|
||||||
|
mPtr = ptr;
|
||||||
|
|
||||||
|
// Conditionally retain object lifetime if T supports intrusive refcount
|
||||||
|
// runtime check: only strong ref if T inherits StrongRefBase
|
||||||
|
if constexpr (std::is_base_of_v<StrongRefBase, T>)
|
||||||
|
{
|
||||||
|
mPtr->incRefCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void release()
|
||||||
|
{
|
||||||
|
if (mPtr)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_base_of_v<StrongRefBase, T>)
|
||||||
|
{
|
||||||
|
mPtr->decRefCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ptr )
|
mPtr = NULL;
|
||||||
{
|
mControl.reset();
|
||||||
ptr->incRefCount();
|
|
||||||
mReference = ptr->getWeakReference();
|
|
||||||
mReference->incRefCount();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
mReference = NULL;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
|
||||||
|
|
||||||
inline void WeakRefBase::clearWeakReferences()
|
|
||||||
{
|
|
||||||
if (mReference)
|
|
||||||
{
|
|
||||||
mReference->mObject = NULL;
|
|
||||||
mReference->decRefCount();
|
|
||||||
mReference = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline WeakRefBase::WeakReference* WeakRefBase::getWeakReference()
|
|
||||||
{
|
|
||||||
if (!mReference)
|
|
||||||
{
|
|
||||||
mReference = new WeakReference(this);
|
|
||||||
mReference->incRefCount();
|
|
||||||
}
|
|
||||||
return mReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct TypeTraits< WeakRefPtr< T > > : public _TypeTraits< WeakRefPtr< T > >
|
struct TypeTraits< WeakRefPtr< T > > : public _TypeTraits< WeakRefPtr< T > >
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1094,7 +1094,7 @@ void ScatterSky::_render( ObjectRenderInst *ri, SceneRenderState *state, BaseMat
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GFX->setCubeTexture( 0, NULL );
|
GFX->setTexture( 0, NULL );
|
||||||
mShaderConsts->setSafe( mUseCubemapSC, 0.0f );
|
mShaderConsts->setSafe( mUseCubemapSC, 0.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -57,6 +57,24 @@
|
||||||
#include "gfx/gl/tGL/tXGL.h"
|
#include "gfx/gl/tGL/tXGL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma region GL WARNINGS
|
||||||
|
|
||||||
|
// #131204 - Texture state usage warning: The texture object (0) bound to texture image unit 0
|
||||||
|
#define GL_LOW_WARN_TEXTURE_STATE 131204
|
||||||
|
|
||||||
|
// #131169 - Framebuffer detailed info: The driver allocated storage for renderbuffer 2. (severity: low)
|
||||||
|
#define GL_LOW_WARN_FRAMEBUFFER 131169
|
||||||
|
|
||||||
|
// #131185 - Buffer detailed info: Buffer object 1 (bound to GL_ELEMENT_ARRAY_BUFFER_ARB, usage hint is GL_ENUM_88e4)
|
||||||
|
// will use VIDEO memory as the source for buffer object operations. (severity: low)
|
||||||
|
#define GL_LOW_WARN_VIDEO_MEMORY 131185
|
||||||
|
|
||||||
|
// #131218 - Program/shader state performance warning: Vertex shader in program #
|
||||||
|
// is being recompiled based on GL state. (severity: medium)
|
||||||
|
#define GL_MED_WARN_PERFORMANCE_RECOMPILE 131218
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
GFXAdapter::CreateDeviceInstanceDelegate GFXGLDevice::mCreateDeviceInstance(GFXGLDevice::createInstance);
|
GFXAdapter::CreateDeviceInstanceDelegate GFXGLDevice::mCreateDeviceInstance(GFXGLDevice::createInstance);
|
||||||
|
|
||||||
GFXDevice *GFXGLDevice::createInstance( U32 adapterIndex )
|
GFXDevice *GFXGLDevice::createInstance( U32 adapterIndex )
|
||||||
|
|
@ -104,6 +122,10 @@ void APIENTRY glDebugCallback(
|
||||||
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION)
|
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Silence: Texture state usage warning: The texture object (0) bound to texture image unit 0
|
||||||
|
if (id == GL_LOW_WARN_TEXTURE_STATE)
|
||||||
|
return;
|
||||||
|
|
||||||
const char* srcStr = "UNKNOWN";
|
const char* srcStr = "UNKNOWN";
|
||||||
const char* typeStr = "UNKNOWN";
|
const char* typeStr = "UNKNOWN";
|
||||||
const char* sevStr = "UNKNOWN";
|
const char* sevStr = "UNKNOWN";
|
||||||
|
|
|
||||||
|
|
@ -480,10 +480,9 @@ bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, GBitmap *pDL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ImageUtil::isCompressedFormat(pDL->getFormat()))
|
if (mipLevels > 1 && !ImageUtil::isCompressedFormat(pDL->getFormat()))
|
||||||
glGenerateMipmap(texture->getBinding());
|
glGenerateMipmap(texture->getBinding());
|
||||||
|
|
||||||
glBindTexture(target, 0);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -560,10 +559,9 @@ bool GFXGLTextureManager::_loadTexture(GFXTextureObject *aTexture, DDSFile *dds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numMips != 1 && !isCompressed)
|
if (numMips > 1 && !isCompressed)
|
||||||
glGenerateMipmap(texture->getBinding());
|
glGenerateMipmap(texture->getBinding());
|
||||||
|
|
||||||
glBindTexture(target, 0);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -608,7 +606,7 @@ bool GFXGLTextureManager::_refreshTexture(GFXTextureObject *texture)
|
||||||
_loadTexture(texture, texture->mBitmap);
|
_loadTexture(texture, texture->mBitmap);
|
||||||
|
|
||||||
if(texture->mDDS)
|
if(texture->mDDS)
|
||||||
return false;
|
_loadTexture(texture, texture->mDDS);
|
||||||
|
|
||||||
usedStrategies++;
|
usedStrategies++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,79 +102,36 @@ GFXLockedRect* GFXGLTextureObject::lock(U32 mipLevel /*= 0*/, RectI* inRect /*=
|
||||||
|
|
||||||
void GFXGLTextureObject::unlock(U32 mipLevel /*= 0*/, U32 faceIndex /*= 0*/)
|
void GFXGLTextureObject::unlock(U32 mipLevel /*= 0*/, U32 faceIndex /*= 0*/)
|
||||||
{
|
{
|
||||||
if (!mLockedRect.bits)
|
if (!mLockedRect.bits)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PROFILE_SCOPE(GFXGLTextureObject_unlock);
|
// I know this is in unlock, but in GL we actually do our submission in unlock.
|
||||||
|
PROFILE_SCOPE(GFXGLTextureObject_lockRT);
|
||||||
|
|
||||||
PRESERVE_TEXTURE(mBinding);
|
PRESERVE_TEXTURE(mBinding);
|
||||||
glBindTexture(mBinding, mHandle);
|
glBindTexture(mBinding, mHandle);
|
||||||
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mBuffer);
|
||||||
|
glBufferData(GL_PIXEL_UNPACK_BUFFER, (mLockedRectRect.extent.x + 1) * (mLockedRectRect.extent.y + 1) * mBytesPerTexel, mFrameAllocatorPtr, GL_STREAM_DRAW);
|
||||||
|
S32 z = getDepth();
|
||||||
|
if (mBinding == GL_TEXTURE_3D)
|
||||||
|
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,
|
||||||
|
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),
|
||||||
|
(mLockedRectRect.extent.x > 1 ? mLockedRectRect.extent.x : mLockedRectRect.extent.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
|
||||||
|
|
||||||
// --- Save pixel store state ---
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||||
GLint prevUnpackAlign;
|
|
||||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &prevUnpackAlign);
|
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
mLockedRect.bits = NULL;
|
||||||
|
#if TORQUE_DEBUG
|
||||||
const U32 width = mLockedRectRect.extent.x;
|
AssertFatal(mFrameAllocatorMarkGuard == FrameAllocator::getWaterMark(), "");
|
||||||
const U32 height = mLockedRectRect.extent.y;
|
|
||||||
const U32 depth = getDepth();
|
|
||||||
|
|
||||||
if (mBinding == GL_TEXTURE_3D)
|
|
||||||
{
|
|
||||||
glTexSubImage3D(
|
|
||||||
mBinding,
|
|
||||||
mipLevel,
|
|
||||||
mLockedRectRect.point.x,
|
|
||||||
mLockedRectRect.point.y,
|
|
||||||
0,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
depth,
|
|
||||||
GFXGLTextureFormat[mFormat],
|
|
||||||
GFXGLTextureType[mFormat],
|
|
||||||
mLockedRect.bits
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (mBinding == GL_TEXTURE_2D)
|
|
||||||
{
|
|
||||||
glTexSubImage2D(
|
|
||||||
mBinding,
|
|
||||||
mipLevel,
|
|
||||||
mLockedRectRect.point.x,
|
|
||||||
mLockedRectRect.point.y,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
GFXGLTextureFormat[mFormat],
|
|
||||||
GFXGLTextureType[mFormat],
|
|
||||||
mLockedRect.bits
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (mBinding == GL_TEXTURE_1D)
|
|
||||||
{
|
|
||||||
glTexSubImage1D(
|
|
||||||
mBinding,
|
|
||||||
mipLevel,
|
|
||||||
mLockedRectRect.point.x,
|
|
||||||
width,
|
|
||||||
GFXGLTextureFormat[mFormat],
|
|
||||||
GFXGLTextureType[mFormat],
|
|
||||||
mLockedRect.bits
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Restore state ---
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, prevUnpackAlign);
|
|
||||||
|
|
||||||
mLockedRect.bits = NULL;
|
|
||||||
|
|
||||||
FrameAllocator::setWaterMark(mFrameAllocatorMark);
|
|
||||||
mFrameAllocatorMark = 0;
|
|
||||||
mFrameAllocatorPtr = NULL;
|
|
||||||
|
|
||||||
#ifdef TORQUE_DEBUG
|
|
||||||
glCheckErrors();
|
|
||||||
#endif
|
#endif
|
||||||
|
FrameAllocator::setWaterMark(mFrameAllocatorMark);
|
||||||
|
mFrameAllocatorMark = 0;
|
||||||
|
mFrameAllocatorPtr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GFXGLTextureObject::release()
|
void GFXGLTextureObject::release()
|
||||||
|
|
@ -281,7 +238,6 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
||||||
} // face
|
} // face
|
||||||
} // mip
|
} // mip
|
||||||
|
|
||||||
glBindTexture(mBinding, 0);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,6 +254,9 @@ void GFXGLTextureObject::updateTextureSlot(const GFXTexHandle& texHandle, const
|
||||||
const GLenum srcTarget = srcTex->getBinding(); // source binding
|
const GLenum srcTarget = srcTex->getBinding(); // source binding
|
||||||
const bool srcIsCube = (srcTarget == GL_TEXTURE_CUBE_MAP || srcTarget == GL_TEXTURE_CUBE_MAP_ARRAY);
|
const bool srcIsCube = (srcTarget == GL_TEXTURE_CUBE_MAP || srcTarget == GL_TEXTURE_CUBE_MAP_ARRAY);
|
||||||
|
|
||||||
|
PRESERVE_TEXTURE(srcTarget);
|
||||||
|
PRESERVE_TEXTURE(dstTarget);
|
||||||
|
|
||||||
// Determine list of faces to copy from source
|
// Determine list of faces to copy from source
|
||||||
U32 firstFace = 0;
|
U32 firstFace = 0;
|
||||||
U32 faceCount = 1;
|
U32 faceCount = 1;
|
||||||
|
|
@ -435,9 +394,6 @@ void GFXGLTextureObject::updateTextureSlot(const GFXTexHandle& texHandle, const
|
||||||
GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], buffer);
|
GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(dstTarget, 0);
|
|
||||||
glBindTexture(srcTarget, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -462,6 +418,9 @@ void GFXGLTextureObject::initSamplerState(const GFXSamplerStateDesc &ssd)
|
||||||
|
|
||||||
void GFXGLTextureObject::bind(U32 textureUnit)
|
void GFXGLTextureObject::bind(U32 textureUnit)
|
||||||
{
|
{
|
||||||
|
if (!mHandle || mIsZombie)
|
||||||
|
return;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0 + textureUnit);
|
glActiveTexture(GL_TEXTURE0 + textureUnit);
|
||||||
glBindTexture(mBinding, mHandle);
|
glBindTexture(mBinding, mHandle);
|
||||||
GFXGL->getOpenglCache()->setCacheBindedTex(textureUnit, mBinding, mHandle);
|
GFXGL->getOpenglCache()->setCacheBindedTex(textureUnit, mBinding, mHandle);
|
||||||
|
|
|
||||||
|
|
@ -1174,7 +1174,7 @@ GuiControl* GuiInspectorTypeColor::constructEditControl()
|
||||||
if( inspector->isMethod( "onInspectorPreFieldModification" ) )
|
if( inspector->isMethod( "onInspectorPreFieldModification" ) )
|
||||||
{
|
{
|
||||||
dSprintf( szBuffer, sizeof( szBuffer ),
|
dSprintf( szBuffer, sizeof( szBuffer ),
|
||||||
"%d.onInspectorPreFieldModification(\"%s\",\"%s\"); %s(%s, \"%d.onInspectorPostFieldModification(); %d.applyWithoutUndo\", %d.getRoot(), \"%d.applyWithoutUndo\", \"%d.onInspectorDiscardFieldModification(); %%unused=\");",
|
"%d.onInspectorPreFieldModification(\"%s\",\"%s\"); %s(%s, \"%d.onInspectorPostFieldModification(); %d.applyWithoutUndo\", %d.getRoot(), \"%d.applyWithoutUndo\", \"%d.onInspectorDiscardFieldModification(); %$unused=\");",
|
||||||
inspector->getId(), getRawFieldName(), getArrayIndex(),
|
inspector->getId(), getRawFieldName(), getArrayIndex(),
|
||||||
mColorFunction, szColor, inspector->getId(), getId(),
|
mColorFunction, szColor, inspector->getId(), getId(),
|
||||||
getId(),
|
getId(),
|
||||||
|
|
|
||||||
|
|
@ -434,25 +434,22 @@ void dampen(inout Surface surface, sampler2D WetnessTexture, float accumTime, fl
|
||||||
{
|
{
|
||||||
if (degree<=0.0) return;
|
if (degree<=0.0) return;
|
||||||
vec3 n = abs(surface.N);
|
vec3 n = abs(surface.N);
|
||||||
float ang = clamp(n.z, 0.04, 0.96);
|
float ang = 1.1-(abs(surface.N.z)*sign(surface.N.z));
|
||||||
|
|
||||||
float speed = -accumTime*(1.0-surface.linearRoughnessSq)*clamp((2.0-ang), 0.04, 0.96);
|
float speed = accumTime * (1.0 - surface.linearRoughnessSq);
|
||||||
if ((n.x > 0.0) || (n.y > 0.0))
|
vec3 wetoffset = (surface.P+vec3(speed,speed,speed)) * 0.33;
|
||||||
speed *= -1.0;
|
|
||||||
vec2 wetoffset = vec2(speed,speed)*0.1;
|
|
||||||
|
|
||||||
vec3 wetNormal = texture(WetnessTexture, float2(surface.P.xy*0.1+wetoffset)).xyz;
|
vec3 wetNormal = texture(WetnessTexture, wetoffset.xy).xyz * (1.1-(n.z* n.z));
|
||||||
wetNormal = lerp(wetNormal,texture(WetnessTexture,float2(surface.P.zx*0.1+wetoffset)).rgb ,n.y);
|
wetNormal = lerp(wetNormal, texture(WetnessTexture, wetoffset.zx).rgb, n.y);
|
||||||
wetNormal = lerp(wetNormal,texture(WetnessTexture,float2(surface.P.zy*0.1+wetoffset)).rgb ,n.x);
|
wetNormal = lerp(wetNormal, texture(WetnessTexture, wetoffset.zy).rgb, n.x);
|
||||||
surface.N = lerp(surface.N, wetNormal, degree);
|
wetNormal = normalize(wetNormal);
|
||||||
|
float wetness = wetNormal.b* degree;
|
||||||
|
|
||||||
float wetness = texture(WetnessTexture, vec2(surface.P.xy*0.1+wetoffset)).b;
|
wetNormal = normalize(wetNormal * 2.0 - 1.0);
|
||||||
wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zx*0.1+wetoffset)).b,n.y);
|
surface.N = normalize(vec3(surface.N.xy + wetNormal.xy * wetness, surface.N.z));
|
||||||
wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zy*0.1+wetoffset)).b,n.x);
|
|
||||||
wetness = pow(wetness*ang*degree,3);
|
|
||||||
|
|
||||||
surface.roughness = lerp(surface.roughness, 0.04f, wetness);
|
surface.roughness = lerp(surface.roughness, 0.04f, wetness);
|
||||||
surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.6+float3(0.4,0.4,0.4)*wetness, wetness);
|
surface.baseColor = vec4(lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.6+vec3(0.4,0.4,0.4)*wetness, wetness), max(surface.baseColor.a, 0.4* wetness));
|
||||||
surface.metalness = lerp(surface.metalness, 0.96, wetness);
|
surface.metalness = lerp(surface.metalness, 0.96, wetness);
|
||||||
updateSurface(surface);
|
updateSurface(surface);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -436,25 +436,22 @@ void dampen(inout Surface surface, TORQUE_SAMPLER2D(WetnessTexture), float accum
|
||||||
{
|
{
|
||||||
if (degree<=0.0) return;
|
if (degree<=0.0) return;
|
||||||
float3 n = abs(surface.N);
|
float3 n = abs(surface.N);
|
||||||
float ang = clamp(n.z, 0.04, 0.96);
|
float ang = 1.1-(abs(surface.N.z)*sign(surface.N.z));
|
||||||
|
|
||||||
float speed = -accumTime*(1.0-surface.linearRoughnessSq)*clamp((2.0-ang), 0.04, 0.96);
|
float speed = accumTime * (1.0 - surface.linearRoughnessSq);
|
||||||
if ((n.x > 0.0) || (n.y > 0.0))
|
float3 wetoffset = (surface.P+float3(speed,speed,speed)) * 0.33;
|
||||||
speed *= -1.0;
|
|
||||||
float2 wetoffset = float2(speed,speed)*0.1;
|
|
||||||
|
|
||||||
float3 wetNormal = TORQUE_TEX2D(WetnessTexture, float2(surface.P.xy*0.1+wetoffset)).xyz;
|
float3 wetNormal = TORQUE_TEX2D(WetnessTexture, wetoffset.xy).xyz * (1.1-(n.z* n.z));
|
||||||
wetNormal = lerp(wetNormal,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zx*0.1+wetoffset)).rgb ,n.y);
|
wetNormal = lerp(wetNormal, TORQUE_TEX2D(WetnessTexture, wetoffset.zx).rgb, n.y);
|
||||||
wetNormal = lerp(wetNormal,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.1+wetoffset)).rgb ,n.x);
|
wetNormal = lerp(wetNormal, TORQUE_TEX2D(WetnessTexture, wetoffset.zy).rgb, n.x);
|
||||||
surface.N = lerp(surface.N, wetNormal, degree);
|
wetNormal = normalize(wetNormal);
|
||||||
|
float wetness = wetNormal.b* degree;
|
||||||
|
|
||||||
float wetness = TORQUE_TEX2D(WetnessTexture, float2(surface.P.xy*0.1+wetoffset)).b;
|
wetNormal = normalize(wetNormal * 2.0 - 1.0);
|
||||||
wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zx*0.1+wetoffset)).b,n.y);
|
surface.N = normalize(float3(surface.N.xy + wetNormal.xy * wetness, surface.N.z));
|
||||||
wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.1+wetoffset)).b,n.x);
|
|
||||||
wetness = pow(wetness*ang*degree,3);
|
|
||||||
|
|
||||||
surface.roughness = lerp(surface.roughness, 0.04f, wetness);
|
surface.roughness = lerp(surface.roughness, 0.04f, wetness);
|
||||||
surface.baseColor.rgb = lerp(surface.baseColor.rgb, surface.baseColor.rgb*0.6+float3(0.4,0.4,0.4)*wetness, wetness);
|
surface.baseColor = float4(lerp(surface.baseColor.rgb, surface.baseColor.rgb * 0.6 + float3(0.4, 0.4, 0.4) * wetness, wetness), max(surface.baseColor.a, 0.4* wetness));
|
||||||
surface.metalness = lerp(surface.metalness, 0.96, wetness);
|
surface.metalness = lerp(surface.metalness, 0.96, wetness);
|
||||||
surface.Update();
|
surface.Update();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2101,7 +2101,7 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj )
|
||||||
%popup.item[ 0 ] = "Delete" TAB "" TAB "EditorMenuEditDelete();";
|
%popup.item[ 0 ] = "Delete" TAB "" TAB "EditorMenuEditDelete();";
|
||||||
%popup.item[ 1 ] = "Group" TAB "" TAB "EWorldEditor.addSimGroup( true );";
|
%popup.item[ 1 ] = "Group" TAB "" TAB "EWorldEditor.addSimGroup( true );";
|
||||||
%popup.item[ 2 ] = "-";
|
%popup.item[ 2 ] = "-";
|
||||||
%popup.item[ 3 ] = "Make selected a Prefab" TAB "" TAB "EWorldEditor.makeSelectionPrefab();";
|
%popup.item[ 3 ] = "Make selected a Prefab" TAB "" TAB "EditorMakePrefab();";
|
||||||
%popup.item[ 4 ] = "Bake selected into Mesh" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ShapeAsset\", AssetBrowser.selectedModule, \"makeSelectedAMesh\");";
|
%popup.item[ 4 ] = "Bake selected into Mesh" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ShapeAsset\", AssetBrowser.selectedModule, \"makeSelectedAMesh\");";
|
||||||
%popup.item[ 5 ] = "-";
|
%popup.item[ 5 ] = "-";
|
||||||
%popup.item[ 6 ] = "Make selected a Sub-Level" TAB "" TAB "MakeSelectionASublevel();";
|
%popup.item[ 6 ] = "Make selected a Sub-Level" TAB "" TAB "MakeSelectionASublevel();";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue