Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node masks signed/unsigned mismatch #3072

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/opencs/view/render/cameracontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace CSVRender
{
// Try again without any mask
boundsVisitor.reset();
boundsVisitor.setTraversalMask(~0);
boundsVisitor.setTraversalMask(~0u);
root->accept(boundsVisitor);

// Last resort, set a default
Expand Down Expand Up @@ -458,7 +458,7 @@ namespace CSVRender
, mDown(false)
, mRollLeft(false)
, mRollRight(false)
, mPickingMask(~0)
, mPickingMask(~0u)
, mCenter(0,0,0)
, mDistance(0)
, mOrbitSpeed(osg::PI / 4)
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/render/mask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace CSVRender
/// @note See the respective file in OpenMW (apps/openmw/mwrender/vismask.hpp)
/// for general usage hints about node masks.
/// @copydoc MWRender::VisMask
enum Mask
enum Mask : unsigned int
{
// elements that are part of the actual scene
Mask_Reference = 0x2,
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/render/scenewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void RenderWidget::flagAsModified()
mView->requestRedraw();
}

void RenderWidget::setVisibilityMask(int mask)
void RenderWidget::setVisibilityMask(unsigned int mask)
{
mView->getCamera()->setCullMask(mask | Mask_ParticleSystem | Mask_Lighting);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/render/scenewidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace CSVRender
/// Initiates a request to redraw the view
void flagAsModified();

void setVisibilityMask(int mask);
void setVisibilityMask(unsigned int mask);

osg::Camera *getCamera();

Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/render/worldspacewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()

void CSVRender::WorldspaceWidget::centerOrbitCameraOnSelection()
{
std::vector<osg::ref_ptr<TagBase> > selection = getSelection(~0);
std::vector<osg::ref_ptr<TagBase> > selection = getSelection(~0u);

for (std::vector<osg::ref_ptr<TagBase> >::iterator it = selection.begin(); it!=selection.end(); ++it)
{
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwrender/characterpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ namespace MWRender
visitor.setTraversalNumber(mDrawOnceCallback->getLastRenderedFrame());

osg::Node::NodeMask nodeMask = mCamera->getNodeMask();
mCamera->setNodeMask(~0);
mCamera->setNodeMask(~0u);
mCamera->accept(visitor);
mCamera->setNodeMask(nodeMask);

Expand Down
6 changes: 3 additions & 3 deletions apps/openmw/mwrender/renderingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ namespace MWRender
}
else if (mode == Render_Scene)
{
int mask = mViewer->getCamera()->getCullMask();
unsigned int mask = mViewer->getCamera()->getCullMask();
bool enabled = mask&Mask_Scene;
enabled = !enabled;
if (enabled)
Expand Down Expand Up @@ -815,7 +815,7 @@ namespace MWRender
return false;
}

int maskBackup = mPlayerAnimation->getObjectRoot()->getNodeMask();
unsigned int maskBackup = mPlayerAnimation->getObjectRoot()->getNodeMask();

if (mCamera->isFirstPerson())
mPlayerAnimation->getObjectRoot()->setNodeMask(0);
Expand Down Expand Up @@ -916,7 +916,7 @@ namespace MWRender
mIntersectionVisitor->setFrameStamp(mViewer->getFrameStamp());
mIntersectionVisitor->setIntersector(intersector);

int mask = ~0;
unsigned int mask = ~0u;
mask &= ~(Mask_RenderToTexture|Mask_Sky|Mask_Debug|Mask_Effect|Mask_Water|Mask_SimpleWater|Mask_Groundcover);
if (ignorePlayer)
mask &= ~(Mask_Player);
Expand Down
12 changes: 6 additions & 6 deletions apps/openmw/mwrender/sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ class CameraRelativeTransform : public osg::Transform
if (cv->getCullingMode() & osg::CullSettings::FAR_PLANE_CULLING)
++numPlanes;

int mask = 0x1;
int resultMask = cv->getProjectionCullingStack().back().getFrustum().getResultMask();
unsigned int mask = 0x1;
unsigned int resultMask = cv->getProjectionCullingStack().back().getFrustum().getResultMask();
for (unsigned int i=0; i<cv->getProjectionCullingStack().back().getFrustum().getPlaneList().size(); ++i)
{
if (i >= numPlanes)
Expand Down Expand Up @@ -441,7 +441,7 @@ class UnderwaterSwitchCallback : public osg::NodeCallback
class CelestialBody
{
public:
CelestialBody(osg::Group* parentNode, float scaleFactor, int numUvSets, unsigned int visibleMask=~0)
CelestialBody(osg::Group* parentNode, float scaleFactor, int numUvSets, unsigned int visibleMask=~0u)
: mVisibleMask(visibleMask)
{
mGeom = createTexturedQuad(numUvSets);
Expand Down Expand Up @@ -1624,7 +1624,7 @@ void SkyManager::setEnabled(bool enabled)
if (enabled && !mCreated)
create();

mRootNode->setNodeMask(enabled ? Mask_Sky : 0);
mRootNode->setNodeMask(enabled ? Mask_Sky : 0u);

mEnabled = enabled;
}
Expand Down Expand Up @@ -1785,7 +1785,7 @@ void SkyManager::setWeather(const WeatherResult& weather)

mCloudUpdater->setOpacity((1.f-mCloudBlendFactor));
mCloudUpdater2->setOpacity(mCloudBlendFactor);
mCloudMesh2->setNodeMask(mCloudBlendFactor > 0.f ? ~0 : 0);
mCloudMesh2->setNodeMask(mCloudBlendFactor > 0.f ? ~0u : 0);
}

if (mCloudColour != weather.mFogColor)
Expand Down Expand Up @@ -1830,7 +1830,7 @@ void SkyManager::setWeather(const WeatherResult& weather)
mAtmosphereNightUpdater->setFade(mStarsOpacity);
}

mAtmosphereNightNode->setNodeMask(weather.mNight ? ~0 : 0);
mAtmosphereNightNode->setNodeMask(weather.mNight ? ~0u : 0);

mPrecipitationAlpha = weather.mPrecipitationAlpha;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwrender/vismask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace MWRender
/// another mask, or what type of node this mask is usually set on.
/// @note The mask values are not serialized within models, nor used in any other way that would break backwards
/// compatibility if the enumeration values were to be changed. Feel free to change them when it makes sense.
enum VisMask
enum VisMask : unsigned int
{
Mask_UpdateVisitor = 0x1, // reserved for separating UpdateVisitors from CullVisitors

Expand Down
6 changes: 3 additions & 3 deletions apps/openmw/mwrender/water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,11 @@ void Water::update(float dt)
void Water::updateVisible()
{
bool visible = mEnabled && mToggled;
mWaterNode->setNodeMask(visible ? ~0 : 0);
mWaterNode->setNodeMask(visible ? ~0u : 0u);
if (mRefraction)
mRefraction->setNodeMask(visible ? Mask_RenderToTexture : 0);
mRefraction->setNodeMask(visible ? Mask_RenderToTexture : 0u);
if (mReflection)
mReflection->setNodeMask(visible ? Mask_RenderToTexture : 0);
mReflection->setNodeMask(visible ? Mask_RenderToTexture : 0u);
}

bool Water::toggle()
Expand Down
2 changes: 1 addition & 1 deletion components/nifosg/nifloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ namespace NifOsg
return sHiddenNodeMask;
}

unsigned int Loader::sIntersectionDisabledNodeMask = ~0;
unsigned int Loader::sIntersectionDisabledNodeMask = ~0u;

void Loader::setIntersectionDisabledNodeMask(unsigned int mask)
{
Expand Down
4 changes: 2 additions & 2 deletions components/terrain/quadtreeworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class QuadTreeBuilder
osg::ref_ptr<RootNode> mRootNode;
};

QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize)
QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, unsigned int nodeMask, unsigned int preCompileMask, unsigned int borderMask, int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize)
: TerrainGrid(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask)
, mViewDataMap(new ViewDataMap)
, mQuadTreeBuilt(false)
Expand All @@ -256,7 +256,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour
mChunkManagers.push_back(mChunkManager.get());
}

QuadTreeWorld::QuadTreeWorld(osg::Group *parent, Storage *storage, int nodeMask, float lodFactor, float chunkSize)
QuadTreeWorld::QuadTreeWorld(osg::Group *parent, Storage *storage, unsigned int nodeMask, float lodFactor, float chunkSize)
: TerrainGrid(parent, storage, nodeMask)
, mViewDataMap(new ViewDataMap)
, mQuadTreeBuilt(false)
Expand Down
4 changes: 2 additions & 2 deletions components/terrain/quadtreeworld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace Terrain
class QuadTreeWorld : public TerrainGrid // note: derived from TerrainGrid is only to render default cells (see loadCell)
{
public:
QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize);
QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, unsigned int nodeMask, unsigned int preCompileMask, unsigned int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize);

QuadTreeWorld(osg::Group *parent, Storage *storage, int nodeMask, float lodFactor, float chunkSize);
QuadTreeWorld(osg::Group *parent, Storage *storage, unsigned int nodeMask, float lodFactor, float chunkSize);

~QuadTreeWorld();

Expand Down
4 changes: 2 additions & 2 deletions components/terrain/terraingrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class MyView : public View
void reset() override {}
};

TerrainGrid::TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask)
TerrainGrid::TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, unsigned int nodeMask, unsigned int preCompileMask, unsigned int borderMask)
: Terrain::World(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask)
, mNumSplits(4)
{
}

TerrainGrid::TerrainGrid(osg::Group* parent, Storage* storage, int nodeMask)
TerrainGrid::TerrainGrid(osg::Group* parent, Storage* storage, unsigned int nodeMask)
: Terrain::World(parent, storage, nodeMask)
, mNumSplits(4)
{
Expand Down
4 changes: 2 additions & 2 deletions components/terrain/terraingrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace Terrain
class TerrainGrid : public Terrain::World
{
public:
TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask=~0, int borderMask=0);
TerrainGrid(osg::Group* parent, Storage* storage, int nodeMask=~0);
TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, unsigned int nodeMask, unsigned int preCompileMask=~0u, unsigned int borderMask=0);
TerrainGrid(osg::Group* parent, Storage* storage, unsigned int nodeMask=~0u);
~TerrainGrid();

void cacheCell(View* view, int x, int y) override;
Expand Down
4 changes: 2 additions & 2 deletions components/terrain/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Terrain
{

World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask)
World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, unsigned int nodeMask, unsigned int preCompileMask, unsigned int borderMask)
: mStorage(storage)
, mParent(parent)
, mResourceSystem(resourceSystem)
Expand Down Expand Up @@ -49,7 +49,7 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
mResourceSystem->addResourceManager(mTextureManager.get());
}

World::World(osg::Group* parent, Storage* storage, int nodeMask)
World::World(osg::Group* parent, Storage* storage, unsigned int nodeMask)
: mStorage(storage)
, mParent(parent)
, mCompositeMapCamera(nullptr)
Expand Down
4 changes: 2 additions & 2 deletions components/terrain/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ namespace Terrain
/// @param storage Storage instance to get terrain data from (heights, normals, colors, textures..)
/// @param nodeMask mask for the terrain root
/// @param preCompileMask mask for pre compiling textures
World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask);
World(osg::Group* parent, Storage* storage, int nodeMask);
World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, unsigned int nodeMask, unsigned int preCompileMask, unsigned int borderMask);
World(osg::Group* parent, Storage* storage, unsigned int nodeMask);
virtual ~World();

/// Set a WorkQueue to delete objects in the background thread.
Expand Down