/********************************************************************* * * _HandleSetValue */ static void _HandleSetValue(RADIO_Handle hObj, RADIO_Obj* pObj, int v) { if (v < 0) { WM_HWIN hWin = _GetPrevInGroup(hObj, pObj->GroupId); if (hWin) { WM_SetFocus(hWin); _SetValue(hWin, 0x7FFF); RADIO__SetValue(hObj, pObj, -1); } } else if (v >= pObj->NumItems) { WM_HWIN hWin = _GetNextInGroup(pObj->Widget.Win.hNext, pObj->GroupId); if (hWin) { WM_SetFocus(hWin); _SetValue(hWin, 0); RADIO__SetValue(hObj, pObj, -1); } } else { if (pObj->Sel != v) { _ClearSelection(hObj, pObj->GroupId); RADIO__SetValue(hObj, pObj, v); } } }
/********************************************************************* * * RADIO_SetGroupId */ void RADIO_SetGroupId(RADIO_Handle hObj, U8 NewGroupId) { if (hObj) { RADIO_Obj* pObj; U8 OldGroupId; WM_LOCK(); pObj = RADIO_H2P(hObj); OldGroupId = pObj->GroupId; if (NewGroupId != OldGroupId) { WM_HWIN hFirst; hFirst = WM__GetFirstSibling(hObj); /* Set function pointer if necessary */ if (NewGroupId && (RADIO__pfHandleSetValue == NULL)) { RADIO__pfHandleSetValue = _HandleSetValue; } /* Pass our selection, if we have one, to another radio button in */ /* our old group. So the group have a valid selection when we leave it. */ if (OldGroupId && (pObj->Sel >= 0)) { WM_HWIN hWin; pObj->GroupId = 0; /* Leave group first, so _GetNextInGroup() could */ /* not find a handle to our own window. */ hWin = _GetNextInGroup(hFirst, OldGroupId); if (hWin) { _SetValue(hWin, 0); } } /* Make sure we have a valid selection according to our new group */ if (_GetNextInGroup(hFirst, NewGroupId) != 0) { /* Join an existing group with an already valid selection, so clear our own one */ RADIO__SetValue(hObj, pObj, -1); } else if (pObj->Sel < 0) { /* We are the first window in group, so we must have a valid selection at our own. */ RADIO__SetValue(hObj, pObj, 0); } /* Change the group */ pObj->GroupId = NewGroupId; } WM_UNLOCK(); } }
void UsdMayaGLBatchRenderer::TaskDelegate::SetCameraState( const GfMatrix4d& viewMatrix, const GfMatrix4d& projectionMatrix, const GfVec4d& viewport) { // cache the camera matrices _ValueCache &cache = _valueCacheMap[_cameraId]; cache[HdStCameraTokens->worldToViewMatrix] = VtValue(viewMatrix); cache[HdStCameraTokens->projectionMatrix] = VtValue(projectionMatrix); cache[HdStCameraTokens->windowPolicy] = VtValue(); // no window policy. // invalidate the camera to be synced GetRenderIndex().GetChangeTracker().MarkSprimDirty(_cameraId, HdStCamera::AllDirty); if( _viewport != viewport ) { // viewport is also read by HdxRenderTaskParam. invalidate it. _viewport = viewport; // update all render tasks for( const auto &it : _renderTaskIdMap ) { SdfPath const &taskId = it.second; HdxRenderTaskParams taskParams = _GetValue<HdxRenderTaskParams>(taskId, HdTokens->params); // update viewport in HdxRenderTaskParams taskParams.viewport = viewport; _SetValue(taskId, HdTokens->params, taskParams); // invalidate GetRenderIndex().GetChangeTracker().MarkTaskDirty( taskId, HdChangeTracker::DirtyParams); } } }
HdTaskSharedPtr UsdMayaGLBatchRenderer::TaskDelegate::GetRenderTask( size_t hash, RenderParams const &renderParams, SdfPathVector const &roots) { // select bucket SdfPath renderTaskId; if( !TfMapLookup(_renderTaskIdMap, hash, &renderTaskId) ) { // create new render task if not exists renderTaskId = _rootId.AppendChild( TfToken(TfStringPrintf("renderTask%zx", hash))); _InsertRenderTask(renderTaskId); _renderTaskIdMap[hash] = renderTaskId; } // // XXX: The Maya-Hydra plugin needs refactoring such that the plugin is // creating a different collection name for each collection it is trying to // manage. (i.e. Each collection within a frame that has different content // should have a different collection name) // // With Hydra, changing the contents of a collection can be // an expensive operation as it causes draw batches to be rebuilt. // // The Maya-Hydra Plugin is currently reusing the same collection // name for all collections within a frame. // (This stems from a time when collection name had a significant meaning // rather than id'ing a collection). // // The plugin should also track deltas to the contents of a collection // and set Hydra's dirty state when prims get added and removed from // the collection. // // Another possible change that can be made to this code is HdxRenderTask // now takes an array of collections, so it is possible to support different // reprs using the same task. Therefore, this code should be modified to // only add one task that is provided with the active set of collections. // // However, a further improvement to the code could be made using // UsdDelegate's fallback repr feature instead of using multiple // collections as it would avoid modifying the collection as a Maya shape // object display state changes. This would result in a much cheaper state // transition within Hydra itself. // TfToken colName = renderParams.geometryCol; HdRprimCollection rprims(colName, renderParams.drawRepr); rprims.SetRootPaths(roots); rprims.SetRenderTags(renderParams.renderTags); GetRenderIndex().GetChangeTracker().MarkCollectionDirty(colName); // update value cache _SetValue(renderTaskId, HdTokens->collection, rprims); // invalidate GetRenderIndex().GetChangeTracker().MarkTaskDirty( renderTaskId, HdChangeTracker::DirtyCollection); // update render params in the value cache HdxRenderTaskParams taskParams = _GetValue<HdxRenderTaskParams>(renderTaskId, HdTokens->params); // update params taskParams.overrideColor = renderParams.overrideColor; taskParams.wireframeColor = renderParams.wireframeColor; taskParams.enableLighting = renderParams.enableLighting; taskParams.enableIdRender = false; taskParams.alphaThreshold = 0.1; taskParams.tessLevel = 32.0; const float tinyThreshold = 0.9f; taskParams.drawingRange = GfVec2f(tinyThreshold, -1.0f); taskParams.depthBiasUseDefault = true; taskParams.depthFunc = HdCmpFuncLess; taskParams.cullStyle = renderParams.cullStyle; taskParams.geomStyle = HdGeomStylePolygons; taskParams.enableHardwareShading = true; // note that taskParams.rprims and taskParams.viewport are not updated // in this function, and needed to be preserved. // store into cache _SetValue(renderTaskId, HdTokens->params, taskParams); // invalidate GetRenderIndex().GetChangeTracker().MarkTaskDirty( renderTaskId, HdChangeTracker::DirtyParams); return GetRenderIndex().GetTask(renderTaskId); }
void UsdMayaGLBatchRenderer::TaskDelegate::_SetLightingStateFromLightingContext() { const GlfSimpleLightVector& lights = _lightingContext->GetLights(); bool hasNumLightsChanged = false; // Insert light Ids into the render index for those that do not yet exist. while (_lightIds.size() < lights.size()) { SdfPath lightId( TfStringPrintf("%s/light%d", _rootId.GetText(), (int)_lightIds.size())); _lightIds.push_back(lightId); // Since we're hardcoded to use HdStRenderDelegate, we expect to have // light Sprims. TF_VERIFY(GetRenderIndex().IsSprimTypeSupported(HdPrimTypeTokens->light)); GetRenderIndex().InsertSprim(HdPrimTypeTokens->light, this, lightId); hasNumLightsChanged = true; } // Remove unused light Ids from HdRenderIndex while (_lightIds.size() > lights.size()) { GetRenderIndex().RemoveSprim(HdPrimTypeTokens->light, _lightIds.back()); _lightIds.pop_back(); hasNumLightsChanged = true; } // invalidate HdLights for (size_t i = 0; i < lights.size(); ++i) { _ValueCache &cache = _valueCacheMap[_lightIds[i]]; // store GlfSimpleLight directly. cache[HdStLightTokens->params] = VtValue(lights[i]); cache[HdStLightTokens->transform] = VtValue(); cache[HdStLightTokens->shadowParams] = VtValue(HdxShadowParams()); cache[HdStLightTokens->shadowCollection] = VtValue(); // Only mark as dirty the parameters to avoid unnecessary invalidation // specially marking as dirty lightShadowCollection will trigger // a collection dirty on geometry and we don't want that to happen // always GetRenderIndex().GetChangeTracker().MarkSprimDirty( _lightIds[i], HdStLight::AllDirty); } // sadly the material also comes from lighting context right now... HdxSimpleLightTaskParams taskParams = _GetValue<HdxSimpleLightTaskParams>(_simpleLightTaskId, HdTokens->params); taskParams.sceneAmbient = _lightingContext->GetSceneAmbient(); taskParams.material = _lightingContext->GetMaterial(); // invalidate HdxSimpleLightTask too if (hasNumLightsChanged) { _SetValue(_simpleLightTaskId, HdTokens->params, taskParams); GetRenderIndex().GetChangeTracker().MarkTaskDirty( _simpleLightTaskId, HdChangeTracker::DirtyParams); } }
void BScrollBar::SetValue(float value) { _SetValue(value, true); }
/********************************************************************* * * EDIT_SetValue */ void EDIT_SetValue(EDIT_Handle hObj, I32 Value) { _SetValue(hObj, Value, 0); }
/********************************************************************* * * EDIT__SetValueUnsigned */ void EDIT__SetValueUnsigned(EDIT_Handle hObj, I32 Value) { _SetValue(hObj, Value, 1); }