void FrameworkView::SetWidget(MetroWidget* aWidget) { NS_ASSERTION(!mWidget, "Attempting to set a widget for a view that already has a widget!"); NS_ASSERTION(aWidget, "Attempting to set a null widget for a view!"); LogFunction(); mWidget = aWidget; mWidget->FindMetroWindow(); UpdateBounds(); }
void UPaperTileMapComponent::ResizeMap(int32 NewWidthInTiles, int32 NewHeightInTiles) { if (OwnsTileMap()) { TileMap->ResizeMap(NewWidthInTiles, NewHeightInTiles); MarkRenderStateDirty(); RecreatePhysicsState(); UpdateBounds(); } }
////////////////////////////////////////////////////////////////////////// // EQS Data ////////////////////////////////////////////////////////////////////////// void UGameplayDebuggingComponent::OnChangeEQSQuery() { AGameplayDebuggingReplicator* Replicator = Cast<AGameplayDebuggingReplicator>(GetOwner()); if (++CurrentEQSIndex >= EQSLocalData.Num()) { CurrentEQSIndex = 0; } UpdateBounds(); MarkRenderStateDirty(); }
//----------------------------------------------------------------------------- // Name: CreateFullScreenDisplay() // Desc: //----------------------------------------------------------------------------- HRESULT CDisplay::CreateFullScreenDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP ) { HRESULT hr; // Cleanup anything from a previous call DestroyObjects(); // DDraw stuff begins here if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL ) ) ) return E_FAIL; // Set cooperative level hr = m_pDD->SetCooperativeLevel( hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN ); if( FAILED(hr) ) return E_FAIL; // Set the display mode if( FAILED( m_pDD->SetDisplayMode( dwWidth, dwHeight, dwBPP, 0, 0 ) ) ) return E_FAIL; // Create primary surface (with backbuffer attached) DDSURFACEDESC2 ddsd; ZeroMemory( &ddsd, sizeof( ddsd ) ); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_3DDEVICE; ddsd.dwBackBufferCount = 1; if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsFrontBuffer, NULL ) ) ) return E_FAIL; // Get a pointer to the back buffer DDSCAPS2 ddscaps; ZeroMemory( &ddscaps, sizeof( ddscaps ) ); ddscaps.dwCaps = DDSCAPS_BACKBUFFER; if( FAILED( hr = m_pddsFrontBuffer->GetAttachedSurface( &ddscaps, &m_pddsBackBuffer ) ) ) return E_FAIL; m_pddsBackBuffer->AddRef(); m_hWnd = hWnd; m_bWindowed = FALSE; UpdateBounds(); return S_OK; }
void Image::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::IMAGE) { MediaBase::OnPropertyChanged (args, error); return; } if (args->GetId () == Image::SourceProperty) { ImageSource *source = args->GetNewValue () ? args->GetNewValue ()->AsImageSource () : NULL; ImageSource *old = args->GetOldValue () ? args->GetOldValue ()->AsImageSource () : NULL; if (old) { if (old->Is(Type::BITMAPSOURCE)) { old->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this); } if (old->Is(Type::BITMAPIMAGE)) { old->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this); old->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this); old->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this); } } if (source) { if (source->Is(Type::BITMAPSOURCE)) { source->AddHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this); } if (source->Is(Type::BITMAPIMAGE)) { source->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this); source->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this); source->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this); } if (source->GetPixelWidth () > 0 && source->GetPixelHeight () > 0) { RoutedEventArgs *args = MoonUnmanagedFactory::CreateRoutedEventArgs (); ImageOpened (args); args->unref (); } } else { UpdateBounds (); Invalidate (); } InvalidateMeasure (); } // we need to notify attachees if our DownloadProgress changed. NotifyListenersOfPropertyChange (args, error); }
void UGeometryCacheComponent::UpdateLocalBounds() { FBox LocalBox(0); for (const FTrackRenderData& Section : TrackSections) { // Use World matrix per section for correct bounding box LocalBox += (Section.MeshData->BoundingBox.TransformBy(Section.WorldMatrix)); } LocalBounds = LocalBox.IsValid ? FBoxSphereBounds(LocalBox) : FBoxSphereBounds(FVector(0, 0, 0), FVector(0, 0, 0), 0); // fallback to reset box sphere bounds UpdateBounds(); }
void FrameworkView::SetDpi(float aDpi) { if (aDpi != mDPI) { LogFunction(); mDPI = aDpi; // notify the widget that dpi has changed if (mWidget) { mWidget->ChangedDPI(); UpdateBounds(); } } }
void FrameworkView::UpdateWidgetSizeAndPosition() { if (mShuttingDown) return; NS_ASSERTION(mWindow, "SetWindow must be called before UpdateWidgetSizeAndPosition!"); NS_ASSERTION(mWidget, "SetWidget must be called before UpdateWidgetSizeAndPosition!"); UpdateBounds(); mWidget->Move(0, 0); mWidget->Resize(0, 0, mWindowBounds.width, mWindowBounds.height, true); mWidget->SizeModeChanged(); }
// コンポーネント登録時の初期化 void USsPlayerComponent::OnRegister() { Super::OnRegister(); if(SsProject) { // Playerの初期化 Player.SetSsProject(SsProject); // 自動再生 if(bAutoPlay) { Player.Play(AutoPlayAnimPackIndex, AutoPlayAnimationIndex, AutoPlayStartFrame, AutoPlayRate, AutoPlayLoopCount, bAutoPlayRoundTrip); Player.bFlipH = bAutoPlayFlipH; Player.bFlipV = bAutoPlayFlipV; UpdateBounds(); } // オフスクリーンレンダリングの初期化 if( (NULL == RenderOffScreen) && ((RenderMode == ESsPlayerComponentRenderMode::OffScreenPlane) || (RenderMode == ESsPlayerComponentRenderMode::OffScreenOnly)) ) { RenderOffScreen = new FSsRenderOffScreen(); } if( (NULL != RenderOffScreen) && !RenderOffScreen->IsInitialized() ) { RenderOffScreen->Initialize(OffScreenRenderResolution.X, OffScreenRenderResolution.Y, SsProject->CalcMaxRenderPartsNum()); // OffScreenPlane用メッシュの初期化 if((RenderMode == ESsPlayerComponentRenderMode::OffScreenPlane) && BaseMaterial) { OffScreenPlaneMID = UMaterialInstanceDynamic::Create(BaseMaterial, this); if(OffScreenPlaneMID) { OffScreenPlaneMID->SetFlags(RF_Transient); OffScreenPlaneMID->SetTextureParameterValue(FName(TEXT("SsRenderTarget")), RenderOffScreen->GetRenderTarget()); if(SceneProxy) { ((FSsRenderPlaneProxy*)SceneProxy)->SetMaterial(OffScreenPlaneMID); } } } } } }
UPaperTileLayer* UPaperTileMapComponent::AddNewLayer() { UPaperTileLayer* Result = nullptr; if (OwnsTileMap()) { Result = TileMap->AddNewLayer(); MarkRenderStateDirty(); RecreatePhysicsState(); UpdateBounds(); } return Result; }
void Border::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::BORDER) { FrameworkElement::OnPropertyChanged (args, error); return; } if (args->GetId () == Border::ChildProperty){ if (args->GetOldValue() && args->GetOldValue()->AsUIElement()) { ElementRemoved (args->GetOldValue()->AsUIElement ()); SetSubtreeObject (NULL); if (args->GetOldValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) { args->GetOldValue()->AsFrameworkElement()->SetLogicalParent (NULL, error); if (error->number) return; } } if (args->GetNewValue() && args->GetNewValue()->AsUIElement()) { SetSubtreeObject (args->GetNewValue()->AsUIElement()); ElementAdded (args->GetNewValue()->AsUIElement ()); if (args->GetNewValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) { FrameworkElement *fwe = args->GetNewValue()->AsFrameworkElement (); if (fwe->GetLogicalParent() && fwe->GetLogicalParent() != this) { MoonError::FillIn (error, MoonError::ARGUMENT, "Content is already a child of another element"); return; } args->GetNewValue()->AsFrameworkElement()->SetLogicalParent (this, error); if (error->number) return; } } UpdateBounds (); InvalidateMeasure (); } else if (args->GetId () == Border::PaddingProperty || args->GetId () == Border::BorderThicknessProperty) { InvalidateMeasure (); } else if (args->GetId () == Border::BackgroundProperty) { Invalidate (); } else if (args->GetId () == Border::BorderBrushProperty) { Invalidate (); } NotifyListenersOfPropertyChange (args, error); }
bool MapCanvas::IsVisible(const Canvas &canvas, const RasterPoint *screen, unsigned num) { PixelRect bounds; bounds.left = 0x7fff; bounds.top = 0x7fff; bounds.right = -1; bounds.bottom = -1; for (unsigned i = 0; i < num; ++i) UpdateBounds(bounds, screen[i]); return bounds.left < (int)canvas.GetWidth() && bounds.right >= 0 && bounds.top < (int)canvas.GetHeight() && bounds.bottom >= 0; }
void Transform::_update(bool updateChildren, bool parentHasChanged) { if (IsEnabled()) { // always clear information about parent notification parentNotified = false; // See if we should process everyone if (needParentUpdate || parentHasChanged) { // Update transforms from parent _updateFromParent(); } /* if (childrenToUpdate.size() > 0) { for_each(childrenToUpdate.begin(), childrenToUpdate.end(), [](Transform::Ptr child){ child->_update(true, false); }); childrenToUpdate.clear(); } */ //if (updateChildren) //{ if (needChildUpdate || parentHasChanged) { for_each(children.begin(), children.end(), [](Transform::Ptr child){ child->_update(true, true); }); } else { for_each(childrenToUpdate.begin(), childrenToUpdate.end(), [](Transform::Ptr child){ child->_update(true, false); }); } childrenToUpdate.clear(); needChildUpdate = false; // Now that the children have been updated, update the this transforms bounds UpdateBounds(); //} } }
void CMultiColumnList::ClearList(bool bClearTitles) { assert(m_vRows.size() > 0); // vector should never be empty vector<string>::iterator it = m_vRows.begin(); if (bClearTitles){ // Get rid of the titles row it = m_vRows.erase(it); m_nColumns = 0; } else it++; while (it != m_vRows.end()) it = m_vRows.erase(it); if (m_vRows.empty()) m_vRows.push_back(string()); UpdateBounds(); }
void CMultiColumnList::AddRow(LPCSTR text){ if (m_nSortBy == -1) { m_vRows.push_back(string(text)); } else { // TODO: TEST THIS, it probably doesn't work // put it in to the vector in the right position vector<string>::iterator it = m_vRows.begin(); string item(GetNthItemInRow(string(text), m_nSortBy)); int row = 0; for (; it != m_vRows.end(); it++){ string rowitem(GetNthItemInRow(m_vRows[row], m_nSortBy)); if (rowitem.compare(item) > 0) { m_vRows.insert(it, string(text)); break; } row++; } } UpdateBounds(); }
void Image::ImageOpened (RoutedEventArgs *args) { BitmapSource *source = (BitmapSource*)GetSource (); if (source->Is (Type::BITMAPIMAGE)) { source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this); source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this); source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this); } InvalidateArrange (); InvalidateMeasure (); UpdateBounds (); Invalidate (); if (HasHandlers (ImageOpenedEvent)) { args->ref (); // to counter the unref in Emit Emit (ImageOpenedEvent, args); } }
void Annotation::Init(GP<GMapArea> pArea, const CSize& szPage, int nRotate) { sourceArea = pArea; if (pArea->border_type == GMapArea::NO_BORDER) nBorderType = BorderNone; else if (pArea->border_type == GMapArea::XOR_BORDER) nBorderType = BorderXOR; else if (pArea->border_type == GMapArea::SHADOW_IN_BORDER) nBorderType = BorderShadowIn; else if (pArea->border_type == GMapArea::SHADOW_OUT_BORDER) nBorderType = BorderShadowOut; else if (pArea->border_type == GMapArea::SHADOW_EIN_BORDER) nBorderType = BorderEtchedIn; else if (pArea->border_type == GMapArea::SHADOW_EOUT_BORDER) nBorderType = BorderEtchedOut; else nBorderType = BorderSolid; if (nBorderType == BorderSolid) { DWORD dwColor = pArea->border_color; crBorder = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor)); } if (pArea->get_shape_type() != GMapArea::RECT && nBorderType > BorderXOR) nBorderType = BorderXOR; nBorderWidth = max(2, min(32, pArea->border_width)); bHideInactiveBorder = !pArea->border_always_visible; if (pArea->hilite_color == 0xffffffff) nFillType = FillNone; else if (pArea->hilite_color == 0xff000000) nFillType = FillXOR; else nFillType = FillSolid; if (nFillType == FillSolid) { DWORD dwColor = pArea->hilite_color; crFill = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor)); } fTransparency = 1.0 - max(0, min(100, pArea->opacity)) / 100.0; if (pArea->is_text) { bAlwaysShowComment = true; DWORD dwColor = pArea->foreground_color; crForeground = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor)); } strComment = pArea->comment; strURL = pArea->url; if (pArea->get_shape_type() == GMapArea::LINE || pArea->get_shape_type() == GMapArea::POLY) { GMapPoly* pPoly = (GMapPoly*)(GMapArea*) pArea; for (int i = 0; i < pPoly->get_points_num(); ++i) { GRect rect(pPoly->get_x(i), pPoly->get_y(i), 1, 1); if (nRotate != 0) Rotate(szPage, nRotate, rect); points.push_back(make_pair(rect.xmin, rect.ymin)); } if (pArea->is_line) { bIsLine = true; bHasArrow = pArea->has_arrow; nLineWidth = max(1, min(32, pArea->line_width)); DWORD dwColor = pArea->foreground_color; crForeground = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor)); } } else { if (pArea->get_shape_type() == GMapArea::OVAL) bOvalShape = true; rects.push_back(pArea->get_bound_rect()); if (nRotate != 0) Rotate(szPage, nRotate, rects.back()); } UpdateBounds(); }
//----------------------------------------------------------------------------- // Purpose: // Input : pBox - //----------------------------------------------------------------------------- void BoundBox::UpdateBounds(const BoundBox *pBox) { UpdateBounds(pBox->bmins, pBox->bmaxs); }
//----------------------------------------------------------------------------- // Name: CreateWindowedDisplay() // Desc: //----------------------------------------------------------------------------- HRESULT CDisplay::CreateWindowedDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight ) { HRESULT hr; // Cleanup anything from a previous call DestroyObjects(); // DDraw stuff begins here if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL ) ) ) return E_FAIL; // Set cooperative level hr = m_pDD->SetCooperativeLevel( hWnd, DDSCL_NORMAL ); if( FAILED(hr) ) return E_FAIL; RECT rcWork; RECT rc; DWORD dwStyle; // If we are still a WS_POPUP window we should convert to a normal app // window so we look like a windows app. dwStyle = GetWindowStyle( hWnd ); dwStyle &= ~WS_POPUP; dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX; SetWindowLong( hWnd, GWL_STYLE, dwStyle ); // Aet window size SetRect( &rc, 0, 0, dwWidth, dwHeight ); AdjustWindowRectEx( &rc, GetWindowStyle(hWnd), GetMenu(hWnd) != NULL, GetWindowExStyle(hWnd) ); SetWindowPos( hWnd, NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); SetWindowPos( hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE ); // Make sure our window does not hang outside of the work area SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 ); GetWindowRect( hWnd, &rc ); if( rc.left < rcWork.left ) rc.left = rcWork.left; if( rc.top < rcWork.top ) rc.top = rcWork.top; SetWindowPos( hWnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); LPDIRECTDRAWCLIPPER pcClipper; // Create the primary surface DDSURFACEDESC2 ddsd; ZeroMemory( &ddsd, sizeof( ddsd ) ); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if( FAILED( m_pDD->CreateSurface( &ddsd, &m_pddsFrontBuffer, NULL ) ) ) return E_FAIL; // Create the backbuffer surface ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; ddsd.dwWidth = dwWidth; ddsd.dwHeight = dwHeight; if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsBackBuffer, NULL ) ) ) return E_FAIL; if( FAILED( hr = m_pDD->CreateClipper( 0, &pcClipper, NULL ) ) ) return E_FAIL; if( FAILED( hr = pcClipper->SetHWnd( 0, hWnd ) ) ) { pcClipper->Release(); return E_FAIL; } if( FAILED( hr = m_pddsFrontBuffer->SetClipper( pcClipper ) ) ) { pcClipper->Release(); return E_FAIL; } // Done with clipper pcClipper->Release(); m_hWnd = hWnd; m_bWindowed = TRUE; UpdateBounds(); return S_OK; }
void CMultiColumnList::SetMaxLines(int max){ m_iMaxLines = max; UpdateBounds(); }
void Annotation::Load(const XMLNode& node) { if (MakeCString(node.tagName) != pszTagAnnotation) return; int borderType; if (node.GetIntAttribute(pszAttrBorder, borderType)) { if (borderType >= BorderNone && borderType <= BorderXOR) nBorderType = borderType; } COLORREF color; if (node.GetColorAttribute(pszAttrBorderColor, color)) crBorder = color; int nHideBorder; if (node.GetIntAttribute(pszAttrBorderHideInactive, nHideBorder)) bHideInactiveBorder = !!nHideBorder; int fillType; if (node.GetIntAttribute(pszAttrFill, fillType)) { if (fillType >= FillNone && fillType <= FillXOR) nFillType = fillType; } if (node.GetColorAttribute(pszAttrFillColor, color)) crFill = color; int nPercent; if (node.GetIntAttribute(pszAttrFillTransparency, nPercent)) { if (nPercent >= 0 && nPercent <= 100) fTransparency = nPercent / 100.0; } int nHideFill; if (node.GetIntAttribute(pszAttrFillHideInactive, nHideFill)) bHideInactiveFill = !!nHideFill; wstring str; if (node.GetAttribute(pszAttrComment, str)) strComment = MakeUTF8String(str); int nShowComment; if (node.GetIntAttribute(pszAttrCommentAlwaysShow, nShowComment)) bAlwaysShowComment = !!nShowComment; if (node.GetAttribute(pszAttrURL, str)) strURL = MakeUTF8String(str); rects.clear(); list<XMLNode>::const_iterator it; for (it = node.childElements.begin(); it != node.childElements.end(); ++it) { const XMLNode& child = *it; if (MakeCString(child.tagName) == pszTagRect) { GRect rect; if (!child.GetIntAttribute(pszAttrLeft, rect.xmin) || !child.GetIntAttribute(pszAttrTop, rect.ymin) || !child.GetIntAttribute(pszAttrRight, rect.xmax) || !child.GetIntAttribute(pszAttrBottom, rect.ymax)) continue; rects.push_back(rect); } } UpdateBounds(); }
void UDestructibleComponent::CreatePhysicsState() { // to avoid calling PrimitiveComponent, I'm just calling ActorComponent::CreatePhysicsState // @todo lh - fix me based on the discussion with Bryan G UActorComponent::CreatePhysicsState(); bPhysicsStateCreated = true; // What we want to do with BodySetup is simply use it to store a PhysicalMaterial, and possibly some other relevant fields. Set up pointers from the BodyInstance to the BodySetup and this component UBodySetup* BodySetup = GetBodySetup(); BodyInstance.OwnerComponent = this; BodyInstance.BodySetup = BodySetup; BodyInstance.InstanceBodyIndex = 0; #if WITH_APEX if( SkeletalMesh == NULL ) { return; } FPhysScene* PhysScene = World->GetPhysicsScene(); check(PhysScene); if( GApexModuleDestructible == NULL ) { UE_LOG(LogPhysics, Log, TEXT("UDestructibleComponent::CreatePhysicsState(): APEX must be enabled to init UDestructibleComponent physics.") ); return; } if( ApexDestructibleActor != NULL ) { UE_LOG(LogPhysics, Log, TEXT("UDestructibleComponent::CreatePhysicsState(): NxDestructibleActor already created.") ); return; } UDestructibleMesh* TheDestructibleMesh = GetDestructibleMesh(); if( TheDestructibleMesh == NULL || TheDestructibleMesh->ApexDestructibleAsset == NULL) { UE_LOG(LogPhysics, Log, TEXT("UDestructibleComponent::CreatePhysicsState(): No DestructibleMesh or missing ApexDestructibleAsset.") ); return; } int32 ChunkCount = TheDestructibleMesh->ApexDestructibleAsset->getChunkCount(); // Ensure the chunks start off invisible. RefreshBoneTransforms should make them visible. for (int32 ChunkIndex = 0; ChunkIndex < ChunkCount; ++ChunkIndex) { SetChunkVisible(ChunkIndex, false); } #if WITH_EDITOR if (GIsEditor && !World->IsGameWorld()) { // In the editor, only set the 0 chunk to be visible. if (TheDestructibleMesh->ApexDestructibleAsset->getChunkCount() > 0) { SetChunkVisible(0, true); } return; } #endif // WITH_EDITOR // Only create physics in the game if( !World->IsGameWorld() ) { return; } // Set template actor/body/shape properties // Find the PhysicalMaterial we need to apply to the physics bodies. UPhysicalMaterial* PhysMat = BodyInstance.GetSimplePhysicalMaterial(); // Get the default actor descriptor NxParameterized data from the asset NxParameterized::Interface* ActorParams = TheDestructibleMesh->GetDestructibleActorDesc(PhysMat); // Create PhysX transforms from ComponentToWorld const PxMat44 GlobalPose(PxMat33(U2PQuat(ComponentToWorld.GetRotation())), U2PVector(ComponentToWorld.GetTranslation())); const PxVec3 Scale = U2PVector(ComponentToWorld.GetScale3D()); // Set the transform in the actor descriptor verify( NxParameterized::setParamMat44(*ActorParams,"globalPose",GlobalPose) ); verify( NxParameterized::setParamVec3(*ActorParams,"scale",Scale) ); // Set the (initially) dynamic flag in the actor descriptor // See if we are 'static' verify( NxParameterized::setParamBool(*ActorParams,"dynamic", BodyInstance.bSimulatePhysics != false) ); // Set the sleep velocity frame decay constant (was sleepVelocitySmoothingFactor) - a new feature that should help sleeping in large piles verify( NxParameterized::setParamF32(*ActorParams,"sleepVelocityFrameDecayConstant", 20.0f) ); // Set up the shape desc template // Get collision channel and response PxFilterData PQueryFilterData, PSimFilterData; uint8 MoveChannel = GetCollisionObjectType(); FCollisionResponseContainer CollResponse; if(IsCollisionEnabled()) { // Only enable a collision response if collision is enabled CollResponse = GetCollisionResponseToChannels(); LargeChunkCollisionResponse.SetCollisionResponseContainer(CollResponse); SmallChunkCollisionResponse.SetCollisionResponseContainer(CollResponse); SmallChunkCollisionResponse.SetResponse(ECC_Pawn, ECR_Overlap); } else { // now since by default it will all block, if collision is disabled, we need to set to ignore MoveChannel = ECC_WorldStatic; CollResponse.SetAllChannels(ECR_Ignore); LargeChunkCollisionResponse.SetAllChannels(ECR_Ignore); SmallChunkCollisionResponse.SetAllChannels(ECR_Ignore); } const bool bEnableImpactDamage = IsImpactDamageEnabled(TheDestructibleMesh, 0); const bool bEnableContactModification = TheDestructibleMesh->DefaultDestructibleParameters.DamageParameters.bCustomImpactResistance && TheDestructibleMesh->DefaultDestructibleParameters.DamageParameters.ImpactResistance > 0.f; // Passing AssetInstanceID = 0 so we'll have self-collision AActor* Owner = GetOwner(); CreateShapeFilterData(MoveChannel, GetUniqueID(), CollResponse, 0, 0, PQueryFilterData, PSimFilterData, BodyInstance.bUseCCD, bEnableImpactDamage, false, bEnableContactModification); // Build filterData variations for complex and simple PSimFilterData.word3 |= EPDF_SimpleCollision | EPDF_ComplexCollision; PQueryFilterData.word3 |= EPDF_SimpleCollision | EPDF_ComplexCollision; // Set the filterData in the shape descriptor verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word0", PSimFilterData.word0 ) ); verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word1", PSimFilterData.word1 ) ); verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word2", PSimFilterData.word2 ) ); verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.simulationFilterData.word3", PSimFilterData.word3 ) ); verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word0", PQueryFilterData.word0 ) ); verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word1", PQueryFilterData.word1 ) ); verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word2", PQueryFilterData.word2 ) ); verify( NxParameterized::setParamU32(*ActorParams,"p3ShapeDescTemplate.queryFilterData.word3", PQueryFilterData.word3 ) ); // Set the PhysX material in the shape descriptor PxMaterial* PMaterial = PhysMat->GetPhysXMaterial(); verify( NxParameterized::setParamU64(*ActorParams,"p3ShapeDescTemplate.material", (physx::PxU64)PMaterial) ); // Set the rest depth to match the skin width in the shape descriptor const physx::PxCookingParams& CookingParams = GApexSDK->getCookingInterface()->getParams(); verify( NxParameterized::setParamF32(*ActorParams,"p3ShapeDescTemplate.restOffset", -CookingParams.skinWidth) ); // Set the PhysX material in the actor descriptor verify( NxParameterized::setParamBool(*ActorParams,"p3ActorDescTemplate.flags.eDISABLE_GRAVITY",false) ); verify( NxParameterized::setParamBool(*ActorParams,"p3ActorDescTemplate.flags.eVISUALIZATION",true) ); // Set the PxActor's and PxShape's userData fields to this component's body instance verify( NxParameterized::setParamU64(*ActorParams,"p3ActorDescTemplate.userData", 0 ) ); // All shapes created by this DestructibleActor will have the userdata of the owning component. // We need this, as in some cases APEX is moving shapes accross actors ( ex. FormExtended structures ) verify( NxParameterized::setParamU64(*ActorParams,"p3ShapeDescTemplate.userData", (PxU64)&PhysxUserData ) ); // Set up the body desc template in the actor descriptor verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.angularDamping", BodyInstance.AngularDamping ) ); verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.linearDamping", BodyInstance.LinearDamping ) ); const PxTolerancesScale& PScale = GPhysXSDK->getTolerancesScale(); PxF32 SleepEnergyThreshold = 0.00005f*PScale.speed*PScale.speed; // 1/1000 Default, since the speed scale is quite high if (BodyInstance.SleepFamily == ESleepFamily::Sensitive) { SleepEnergyThreshold /= 20.0f; } verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.sleepThreshold", SleepEnergyThreshold) ); // NxParameterized::setParamF32(*ActorParams,"bodyDescTemplate.sleepDamping", SleepDamping ); verify( NxParameterized::setParamF32(*ActorParams,"p3BodyDescTemplate.density", 0.001f*PhysMat->Density) ); // Convert from g/cm^3 to kg/cm^3 // Enable CCD if requested verify( NxParameterized::setParamBool(*ActorParams,"p3BodyDescTemplate.flags.eENABLE_CCD", BodyInstance.bUseCCD != 0) ); // Ask the actor to create chunk events, for more efficient visibility updates verify( NxParameterized::setParamBool(*ActorParams,"createChunkEvents", true) ); // Enable hard sleeping if requested verify( NxParameterized::setParamBool(*ActorParams,"useHardSleeping", bEnableHardSleeping) ); // Destructibles are always dynamic or kinematic, and therefore only go into one of the scenes const uint32 SceneType = BodyInstance.UseAsyncScene(PhysScene) ? PST_Async : PST_Sync; NxApexScene* ApexScene = PhysScene->GetApexScene(SceneType); PxScene* PScene = PhysScene->GetPhysXScene(SceneType); BodyInstance.SceneIndexSync = SceneType == PST_Sync ? PhysScene->PhysXSceneIndex[PST_Sync] : 0; BodyInstance.SceneIndexAsync = SceneType == PST_Async ? PhysScene->PhysXSceneIndex[PST_Async] : 0; check(ApexScene); ChunkInfos.Reset(ChunkCount); ChunkInfos.AddZeroed(ChunkCount); PhysxChunkUserData.Reset(ChunkCount); PhysxChunkUserData.AddZeroed(ChunkCount); // Create an APEX NxDestructibleActor from the Destructible asset and actor descriptor ApexDestructibleActor = static_cast<NxDestructibleActor*>(TheDestructibleMesh->ApexDestructibleAsset->createApexActor(*ActorParams, *ApexScene)); check(ApexDestructibleActor); // Make a backpointer to this component PhysxUserData = FPhysxUserData(this); ApexDestructibleActor->userData = &PhysxUserData; // Cache cooked collision data // BRGTODO : cook in asset ApexDestructibleActor->cacheModuleData(); // BRGTODO : Per-actor LOD setting // ApexDestructibleActor->forcePhysicalLod( DestructibleActor->LOD ); // Start asleep if requested PxRigidDynamic* PRootActor = ApexDestructibleActor->getChunkPhysXActor(0); // Put to sleep or wake up only if the component is physics-simulated if (PRootActor != NULL && BodyInstance.bSimulatePhysics) { SCOPED_SCENE_WRITE_LOCK(PScene); //Question, since apex is defer adding actors do we need to lock? Locking the async scene is expensive! PRootActor->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, !BodyInstance.bEnableGravity); // Sleep/wake up as appropriate if (!BodyInstance.bStartAwake) { ApexDestructibleActor->setChunkPhysXActorAwakeState(0, false); } } UpdateBounds(); #endif // #if WITH_APEX }
//----------------------------------------------------------------------// // NavMesh rendering //----------------------------------------------------------------------// void UGameplayDebuggingComponent::OnRep_UpdateNavmesh() { NavMeshBounds = FBox(FVector(-HALF_WORLD_MAX, -HALF_WORLD_MAX, -HALF_WORLD_MAX), FVector(HALF_WORLD_MAX, HALF_WORLD_MAX, HALF_WORLD_MAX)); UpdateBounds(); MarkRenderStateDirty(); }
void pfGUIControlMod::CalcInitialBounds( void ) { UpdateBounds( nil, true ); fInitialBounds = fBounds; }
size_t DfpnSolver::MID(const DfpnBounds& maxBounds, DfpnHistory& history) { maxBounds.CheckConsistency(); SG_ASSERT(maxBounds.phi > 1); SG_ASSERT(maxBounds.delta > 1); ++m_numMIDcalls; size_t prevWork = 0; SgEmptyBlackWhite colorToMove = GetColorToMove(); DfpnData data; if (TTRead(data)) { prevWork = data.m_work; if (! maxBounds.GreaterThan(data.m_bounds)) // Estimated bounds are larger than we had // anticipated. The calling state must have computed // the max bounds with out of date information, so just // return here without doing anything: the caller will // now update to this new info and carry on. return 0; } else { SgEmptyBlackWhite winner = SG_EMPTY; if (TerminalState(colorToMove, winner)) { ++m_numTerminal; DfpnBounds terminal; if (colorToMove == winner) DfpnBounds::SetToWinning(terminal); else { SG_ASSERT(SgOppBW(colorToMove) == winner); DfpnBounds::SetToLosing(terminal); } TTWrite(DfpnData(terminal, SG_NULLMOVE, 1)); return 1; } } ++m_generateMoves; DfpnChildren children; GenerateChildren(children.Children()); // Not thread safe: perhaps move into while loop below later... std::vector<DfpnData> childrenData(children.Size()); for (size_t i = 0; i < children.Size(); ++i) LookupData(childrenData[i], children, i); // Index used for progressive widening size_t maxChildIndex = ComputeMaxChildIndex(childrenData); SgHashCode currentHash = Hash(); SgMove bestMove = SG_NULLMOVE; DfpnBounds currentBounds; size_t localWork = 1; do { UpdateBounds(currentBounds, childrenData, maxChildIndex); if (! maxBounds.GreaterThan(currentBounds)) break; // Select most proving child std::size_t bestIndex = 999999; DfpnBoundType delta2 = DfpnBounds::INFTY; SelectChild(bestIndex, delta2, childrenData, maxChildIndex); bestMove = children.MoveAt(bestIndex); // Compute maximum bound for child const DfpnBounds childBounds(childrenData[bestIndex].m_bounds); DfpnBounds childMaxBounds; childMaxBounds.phi = maxBounds.delta - (currentBounds.delta - childBounds.phi); childMaxBounds.delta = delta2 == DfpnBounds::INFTY ? maxBounds.phi : std::min(maxBounds.phi, std::max(delta2 + 1, DfpnBoundType(delta2 * (1.0 + m_epsilon)))); SG_ASSERT(childMaxBounds.GreaterThan(childBounds)); if (delta2 != DfpnBounds::INFTY) m_deltaIncrease.Add(float(childMaxBounds.delta-childBounds.delta)); // Recurse on best child PlayMove(bestMove); history.Push(bestMove, currentHash); localWork += MID(childMaxBounds, history); history.Pop(); UndoMove(); // Update bounds for best child LookupData(childrenData[bestIndex], children, bestIndex); // Compute some stats when find winning move if (childrenData[bestIndex].m_bounds.IsLosing()) { m_moveOrderingIndex.Add(float(bestIndex)); m_moveOrderingPercent.Add(float(bestIndex) / (float)childrenData.size()); m_totalWastedWork += prevWork + localWork - childrenData[bestIndex].m_work; } else if (childrenData[bestIndex].m_bounds.IsWinning()) maxChildIndex = ComputeMaxChildIndex(childrenData); } while (! CheckAbort()); // Find the most delaying move for losing states, and the smallest // winning move for winning states. if (currentBounds.IsSolved()) { if (currentBounds.IsLosing()) { std::size_t maxWork = 0; for (std::size_t i = 0; i < children.Size(); ++i) { if (childrenData[i].m_work > maxWork) { maxWork = childrenData[i].m_work; bestMove = children.MoveAt(i); } } } else { std::size_t minWork = DfpnBounds::INFTY; for (std::size_t i = 0; i < children.Size(); ++i) { if (childrenData[i].m_bounds.IsLosing() && childrenData[i].m_work < minWork) { minWork = childrenData[i].m_work; bestMove = children.MoveAt(i); } } } } // Store search results TTWrite(DfpnData(currentBounds, bestMove, localWork + prevWork)); return localWork; }
const hsBounds3 &pfGUIControlMod::GetBounds( void ) { UpdateBounds(); return fBounds; }
void DiCullNode::_Update( bool updateChildren, bool parentHasChanged ) { DiNode::_Update(updateChildren, parentHasChanged); UpdateBounds(); }
void pfGUIControlMod::SetTarget( plSceneObject *object ) { plSingleModifier::SetTarget( object ); UpdateBounds(); }
void WdgGraph::Refresh(unsigned int _domainId) { if (!solver.Running()) { domainId = _domainId; bool needsRelax = false, needsBoundsUpdate = false, filterActive = hiFilter.Active(); // // refresh nodes // IgNodeMap nodeMap = iv->NodeMap(fm, domainId); WgNodeVector::iterator node = nodes.begin(); while (node != nodes.end()) { IgNodeMap::iterator nodeIt = nodeMap.find(node->id); if (nodeIt != nodeMap.end()) { node->selected = nodeIt->second.selected; node->external = nodeIt->second.external; node->multiuser = nodeIt->second.multiuser; // row found, refresh node if (*node != nodeIt->second) { node->ts = nodeIt->second.ts; node->title = QString::fromUtf8(nodeIt->second.text.c_str()); } nodeMap.erase(nodeIt); node++; } else { // node id not found, delete node if (node->hi.dir != hdNone) --hilitNodes; node = nodes.erase(node); needsRelax = needsBoundsUpdate = true; } } for (IgNodeMap::iterator nodeIt = nodeMap.begin(); nodeIt != nodeMap.end(); ++nodeIt) { if (!filterActive || hiFilter.ContainsNode(nodeIt->first)) { nodes.push_back(WgNode( nodeIt->first, nodeIt->second.ts, nodeIt->second.selected, nodeIt->second.external, nodeIt->second.multiuser, QString::fromUtf8(nodeIt->second.text.c_str()))); needsRelax = needsBoundsUpdate = true; } } // // refresh sub nodes // IgSubNodeMap subNodeMap = iv->SubNodeMap(fm, domainId); WgSubNodeVector::iterator subNode = subNodes.begin(); while (subNode!= subNodes.end()) { IgSubNodeMap::iterator subNodeIt = subNodeMap.find(subNode->id); if (subNodeIt != subNodeMap.end()) { subNode->selected = subNodeIt->second.selected; subNode->external = subNodeIt->second.external; // row found, refresh node if (*subNode != subNodeIt->second) { subNode->ts = subNodeIt->second.ts; subNode->title = QString::fromUtf8(subNodeIt->second.text.c_str()); subNode->im.id = subNodeIt->second.im; } subNodeMap.erase(subNodeIt); subNode++; } else { // node id not found, delete node subNode = subNodes.erase(subNode); needsRelax = needsBoundsUpdate = true; } } for (IgSubNodeMap::iterator subNodeIt = subNodeMap.begin(); subNodeIt != subNodeMap.end(); ++subNodeIt) { if (!filterActive || hiFilter.ContainsSubNode(subNodeIt->first)) { subNodes.push_back(WgSubNode( subNodeIt->first, subNodeIt->second.ts, subNodeIt->second.selected, subNodeIt->second.external, QString::fromUtf8(subNodeIt->second.text.c_str()), subNodeIt->second.im)); needsRelax = needsBoundsUpdate = true; } } if (needsBoundsUpdate) UpdateBounds(); // // refresh links // IgLinkMap linkMap = iv->LinkMap(fm, domainId); WgLinkList::iterator link = links.begin(); while (link != links.end()) { IgLinkMap::iterator linkIt = linkMap.find(link->id); if (linkIt != linkMap.end()) { link->selected = linkIt->second.selected; // row found, refresh link if (*link != linkIt->second) { link->ts = linkIt->second.ts; link->us.id = linkIt->second.us; link->im.id = linkIt->second.im; link->sb.id = linkIt->second.sb; needsRelax = true; } linkMap.erase(linkIt); link++; } else { // link id not found, delete link link = links.erase(link); needsRelax = true; } } for (IgLinkMap::iterator linkIt = linkMap.begin(); linkIt != linkMap.end(); ++linkIt) { if (!filterActive || hiFilter.ContainsLink(linkIt->first)) { links.push_back(WgLink( linkIt->first, linkIt->second.ts, linkIt->second.selected, linkIt->second.us, linkIt->second.im, linkIt->second.sb)); needsRelax = true; } } // // if modified, relax // if (needsRelax) Relax(); updateGL(); } }