fix crash when creating a second view and closing the first view while the dragger task panel is open
This commit is contained in:
parent
f712e1cfc3
commit
776c0bd720
|
@ -910,7 +910,6 @@ void SoFCCSysDragger::setUpAutoScale(SoCamera *cameraIn)
|
|||
//note: sofieldsensor checks if the current sensor is already attached
|
||||
//and takes appropriate action. So it is safe to attach to a field without
|
||||
//checking current attachment state.
|
||||
camera = cameraIn;
|
||||
if (cameraIn->getTypeId() == SoOrthographicCamera::getClassTypeId())
|
||||
{
|
||||
SoOrthographicCamera *localCamera = dynamic_cast<SoOrthographicCamera *>(cameraIn);
|
||||
|
@ -943,28 +942,36 @@ void SoFCCSysDragger::cameraCB(void *data, SoSensor *)
|
|||
void SoFCCSysDragger::idleCB(void *data, SoSensor *)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = reinterpret_cast<SoFCCSysDragger *>(data);
|
||||
assert(sudoThis->camera);
|
||||
SoField* field = sudoThis->cameraSensor.getAttachedField();
|
||||
if (field)
|
||||
{
|
||||
SoCamera* camera = static_cast<SoCamera*>(field->getContainer());
|
||||
SbMatrix localToWorld = sudoThis->getLocalToWorldMatrix();
|
||||
SbVec3f origin;
|
||||
localToWorld.multVecMatrix(SbVec3f(0.0, 0.0, 0.0), origin);
|
||||
|
||||
SbMatrix localToWorld = sudoThis->getLocalToWorldMatrix();
|
||||
SbVec3f origin;
|
||||
localToWorld.multVecMatrix(SbVec3f(0.0, 0.0, 0.0), origin);
|
||||
|
||||
SbViewVolume viewVolume = sudoThis->camera->getViewVolume();
|
||||
float radius = sudoThis->draggerSize.getValue() / 2.0;
|
||||
float localScale = viewVolume.getWorldToScreenScale(origin, radius);
|
||||
SbVec3f scaleVector(localScale, localScale, localScale);
|
||||
SoScale *localScaleNode = SO_GET_ANY_PART(sudoThis, "scaleNode", SoScale);
|
||||
localScaleNode->scaleFactor.setValue(scaleVector);
|
||||
sudoThis->autoScaleResult.setValue(localScale);
|
||||
SbViewVolume viewVolume = camera->getViewVolume();
|
||||
float radius = sudoThis->draggerSize.getValue() / 2.0;
|
||||
float localScale = viewVolume.getWorldToScreenScale(origin, radius);
|
||||
SbVec3f scaleVector(localScale, localScale, localScale);
|
||||
SoScale *localScaleNode = SO_GET_ANY_PART(sudoThis, "scaleNode", SoScale);
|
||||
localScaleNode->scaleFactor.setValue(scaleVector);
|
||||
sudoThis->autoScaleResult.setValue(localScale);
|
||||
}
|
||||
}
|
||||
|
||||
void SoFCCSysDragger::finishDragCB(void *data, SoDragger *)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = reinterpret_cast<SoFCCSysDragger *>(data);
|
||||
|
||||
if (sudoThis->camera)
|
||||
// note: when creating a second view of the document and then closing
|
||||
// the first viewer it deletes the camera. However, the attached field
|
||||
// of the cameraSensor will be detached automatically.
|
||||
SoField* field = sudoThis->cameraSensor.getAttachedField();
|
||||
if (field)
|
||||
{
|
||||
if (sudoThis->camera->getTypeId() == SoPerspectiveCamera::getClassTypeId())
|
||||
SoCamera* camera = static_cast<SoCamera*>(field->getContainer());
|
||||
if (camera->getTypeId() == SoPerspectiveCamera::getClassTypeId())
|
||||
cameraCB(sudoThis, nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,6 @@ public:
|
|||
|
||||
SoIdleSensor idleSensor; //!< might be overkill, but want to make sure of performance.
|
||||
void setUpAutoScale(SoCamera *cameraIn); //!< used to setup the auto scaling of dragger.
|
||||
SoCamera *camera = nullptr; //!< don't assign directly! use setUpAutoScale.
|
||||
|
||||
//! @name Visibility Functions
|
||||
//@{
|
||||
|
|
Loading…
Reference in New Issue
Block a user