USNavalResearchLaboratory / simdissdk

SIMDIS SDK
Other
114 stars 39 forks source link

Projectors: add the ability for multiple projectors (up to 4) to proj… #83

Closed gwaldron closed 2 years ago

gwaldron commented 2 years ago

…ect onto node

Run example_projectors and go to '2' to test.

gwaldron commented 2 years ago

Can you try: projectors_.swap(keep);

The move semantics should be built into the swap function anyway; it will be more efficient than an assignment.

emminizer commented 2 years ago

Yes, projectors_.swap(keep) works fine. I will use that instead.

I do have a warning that I'm not sure how to resolve, that I think is related to osgEarth code. I'm seeing on console with example_projectors and latest osgEarth:

Cannot assign between Uniform types float and vec3
Cannot assign between Uniform types float and vec4

This spams a few times. The callstack is:

>   osgEarthd.dll!osgEarth::Util::ArrayUniform::ensureCapacity(unsigned int newSize) Line 482   C++
    osgEarthd.dll!osgEarth::Util::ArrayUniform::setElement(unsigned int index, const osg::Vec3f & value) Line 402   C++
    sdk16-simVisd.dll!simVis::`anonymous namespace'::copyUniform<osg::Vec3f>(osg::StateSet * ss, osg::Uniform * src, unsigned int size, unsigned int index) Line 492    C++
    sdk16-simVisd.dll!simVis::ProjectorNode::copyUniformsTo(osg::StateSet * stateSet, unsigned int size, unsigned int index) Line 503   C++
    sdk16-simVisd.dll!`anonymous namespace'::ProjectOnNodeUpdater::updateUniforms(osg::StateSet * ss) Line 234  C++
    sdk16-simVisd.dll!`anonymous namespace'::ProjectOnNodeUpdater::configureStateSet(osg::StateSet * ss) Line 224   C++
    sdk16-simVisd.dll!simVis::ProjectorNode::addProjectionToNode(osg::Node * entity, osg::Node * attachmentPoint) Line 1069 C++
    sdk16-simVisd.dll!simVis::EntityNode::acceptProjector(simVis::ProjectorNode * proj) Line 310    C++
    example_projectorsd.exe!main(int argc, char * * argv) Line 508  C++

In ArrayUniform::ensureCapacity(2), it's dropping into the GL_FLOAT case. It fails getElement() call (returns false), then calls setElement() with a float. This is during the vec3/vec4 calls to ProjectorNode::copyUniform() calls, as a result of the second call to gateNode->acceptProjector() in the main(). The warning doesn't seem to impact functionality, presumably because the value gets set again at a later point. But it looks like osgEarth::Util::ArrayUniform doesn't seem set up to handle arrays of vec3 and vec4.

Are you seeing the same warnings? Does the fix belong in ArrayUniform? I'm not familiar with the code but I can take a look at it if desired.

gwaldron commented 2 years ago

I am not seeing those warnings. Are you on an NVIDIA card? I did have to update ArrayUniform to support vec4's, in f9c0f26 .. did you get that update?

emminizer commented 2 years ago

Yes I am on an NVIDIA card. I am on current master and do have f9c0f26.

ArrayUniform::ensureCapacity() has no ability to handle vec4, so it retrieves and sets as a float.

gwaldron commented 2 years ago

OK. I will revisit it..

emminizer commented 2 years ago

If it helps, it looks like this error message only shows up in debug mode, not in release mode (though it is still a problem in release).

gwaldron commented 2 years ago

Ok, I updated osgearth master branch with this fix. Let me know if it works for you

emminizer commented 2 years ago

Thanks! Yes the update to osgEarth master works great. I'm working on trying to integrate Blend2D into our osgEarth build across all our systems and afterwards will merge this in.