bool gfx_light::RemoveFromTable(bool shouldremove, const GFXLight &t) { LineCollideStar tmp; bool err; LineCollide coltarg (CalculateBounds(err)); if (!shouldremove) { bool err2; LineCollide coltarg2 (CalculateBounds (err2)); if (lighttable.hash_int (coltarg2.Mini.i)==lighttable.hash_int (coltarg.Mini.i)&& lighttable.hash_int (coltarg2.Mini.j)==lighttable.hash_int (coltarg.Mini.j)&& lighttable.hash_int (coltarg2.Mini.k)==lighttable.hash_int (coltarg.Mini.k)&& lighttable.hash_int (coltarg2.Maxi.i)==lighttable.hash_int (coltarg.Maxi.i)&& lighttable.hash_int (coltarg2.Maxi.j)==lighttable.hash_int (coltarg.Maxi.j)&& lighttable.hash_int (coltarg2.Maxi.k)==lighttable.hash_int (coltarg.Maxi.k)) { return false; } } if (err) return false; tmp.lc = &coltarg; if (lighttable.Remove ( &coltarg, tmp)) { if (tmp.lc) delete tmp.lc; else assert (tmp.lc); } return true; }
void wish_mesh::SetVertices(r32* vertices, u32 numVertices, u32 vertexSize) { Vertices = vertices; NumVertices = numVertices; VertexSize = vertexSize; CalculateBounds(); }
void CVTOLVehicleManager::RegisterVTOL(EntityId entityId) { if(g_pGameCVars->g_mpNoVTOL) { gEnv->pEntitySystem->RemoveEntity(entityId); } else { RegisterVTOLWithPathFollower(true); IEntity* pVTOLEntity = gEnv->pEntitySystem->GetEntity(entityId); if(pVTOLEntity) { SVTOLInfo& newInfo = m_vtolList[entityId]; newInfo.Reset(); newInfo.playersInside.reserve(8); newInfo.entityId = entityId; newInfo.location = QuatT(pVTOLEntity->GetWorldTM()); CalculateBounds(pVTOLEntity, newInfo); gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_DONE, this); gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_RESET, this); gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_HIDE, this); gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_UNHIDE, this); SetupMovement(entityId); SmartScriptTable props, respawnprops; if (pVTOLEntity->GetScriptTable()->GetValue("Properties", props) && props->GetValue("Respawn", respawnprops)) { respawnprops->SetValue("bAbandon", 0); } } } }
// Recalculates the the control's image quads //------------------------------------------------------------------------ void CPUTCheckbox::Recalculate() { // active/idle AddQuadIntoMirrorBuffer(mpMirrorBufferActive, (float) mControlDimensions.x, (float) mControlDimensions.y, (float) mpCheckboxTextureSizeList[0].width, (float) mpCheckboxTextureSizeList[0].height, mpUVCoordsCheckbox_active[0], mpUVCoordsCheckbox_active[1] ); // pressed AddQuadIntoMirrorBuffer(mpMirrorBufferPressed, (float) mControlDimensions.x, (float)mControlDimensions.y, (float) mpCheckboxTextureSizeList[1].width, (float) mpCheckboxTextureSizeList[1].height, mpUVCoordsCheckbox_pressed[0], mpUVCoordsCheckbox_pressed[1] ); // disabled AddQuadIntoMirrorBuffer(mpMirrorBufferDisabled, (float) mControlDimensions.x, (float) mControlDimensions.y, (float) mpCheckboxTextureSizeList[2].width, (float) mpCheckboxTextureSizeList[2].height, mpUVCoordsCheckbox_disabled[0], mpUVCoordsCheckbox_disabled[1] ); // re-calculate the bounding box for the control used for hit-testing/sizing CalculateBounds(); // Mark this control as 'dirty' for drawing and inform the gui system that // it needs to re-calculate it's drawing buffer CPUTGuiControllerDX11::GetController()->ControlIsDirty(); }
STDMETHODIMP CPDObjectSymbolInstance::Deserialize(/*[in]*/ IArchive* ar, IArchiveElement* node, IUnknown* pUnkExtra) { HRESULT hr; hr = CPDObjectImpl<IPDObjectSymbolInstance>::Deserialize(ar, node, pUnkExtra); if (FAILED(hr)) return hr; hr = CPDObjectTransformableImpl<CPDObjectSymbolInstance>::Deserialize(ar, node, pUnkExtra); if (FAILED(hr)) return hr; hr = CPDObjectWithAppearanceImpl<CPDObjectSymbolInstance, IPDObjectWithAppearance>::Deserialize(ar, node, pUnkExtra); if (FAILED(hr)) return hr; _variant_t v; node->getAttribute(L"x", &v); m_x = v; node->getAttribute(L"y", &v); m_y = v; node->getElement(L"symbol", NULL, (IUnknown**)&m_symbol); CalculateBounds(); return S_OK; }
/* ==================== idMD5Mesh::UpdateSurface ==================== */ void idMD5Mesh::UpdateSurface( const struct renderEntity_s *ent, const idJointMat *entJoints, const idJointMat *entJointsInverted, modelSurface_t *surf ) { tr.pc.c_deformedSurfaces++; tr.pc.c_deformedVerts += deformInfo->numOutputVerts; tr.pc.c_deformedIndexes += deformInfo->numIndexes; surf->shader = shader; if ( surf->geometry != NULL ) { // if the number of verts and indexes are the same we can re-use the triangle surface if ( surf->geometry->numVerts == deformInfo->numOutputVerts && surf->geometry->numIndexes == deformInfo->numIndexes ) { R_FreeStaticTriSurfVertexCaches( surf->geometry ); } else { R_FreeStaticTriSurf( surf->geometry ); surf->geometry = R_AllocStaticTriSurf(); } } else { surf->geometry = R_AllocStaticTriSurf(); } srfTriangles_t * tri = surf->geometry; // note that some of the data is referenced, and should not be freed tri->referencedIndexes = true; tri->numIndexes = deformInfo->numIndexes; tri->indexes = deformInfo->indexes; tri->silIndexes = deformInfo->silIndexes; tri->numMirroredVerts = deformInfo->numMirroredVerts; tri->mirroredVerts = deformInfo->mirroredVerts; tri->numDupVerts = deformInfo->numDupVerts; tri->dupVerts = deformInfo->dupVerts; tri->numSilEdges = deformInfo->numSilEdges; tri->silEdges = deformInfo->silEdges; tri->indexCache = deformInfo->staticIndexCache; tri->numVerts = deformInfo->numOutputVerts; if ( r_useGPUSkinning.GetBool() ) { if ( tri->verts != NULL && tri->verts != deformInfo->verts ) { R_FreeStaticTriSurfVerts( tri ); } tri->verts = deformInfo->verts; tri->ambientCache = deformInfo->staticAmbientCache; tri->shadowCache = deformInfo->staticShadowCache; tri->referencedVerts = true; } else { if ( tri->verts == NULL || tri->verts == deformInfo->verts ) { tri->verts = NULL; R_AllocStaticTriSurfVerts( tri, deformInfo->numOutputVerts ); assert( tri->verts != NULL ); // quiet analyze warning memcpy( tri->verts, deformInfo->verts, deformInfo->numOutputVerts * sizeof( deformInfo->verts[0] ) ); // copy over the texture coordinates } TransformVertsAndTangents( tri->verts, deformInfo->numOutputVerts, deformInfo->verts, entJointsInverted ); tri->referencedVerts = false; } tri->tangentsCalculated = true; CalculateBounds( entJoints, tri->bounds ); }
// INotifyGet STDMETHODIMP CPDObjectFrame::OnChanged(NotifyType type, IUnknown* targetObject, IUnknown* immtargetObject, DISPID dispID) { CalculateBounds(); CComQIPtr<IPDPath> path = immtargetObject; if (path) { if (IsUnknownEqualUnknown(path, m_path->GetUnknown())) { if (m_gdppath) { delete m_gdppath; m_gdppath = NULL; } if (m_wrapPath) { if (m_editedWrapPath == FALSE) { CComQIPtr<INotifySend> cp = m_wrapPath; cp->LockSend(); RecreateWrapPath(); cp->UnlockSend(); } } } } CNotifySendImpl<CPDObjectFrame>::FireOnChanged(type, targetObject, dispID); return S_OK; }
// INotifyGet STDMETHODIMP CPDObjectSymbolInstance::OnChanged(NotifyType type, IUnknown* targetObject, IUnknown* immtargetObject, DISPID dispID) { CalculateBounds(); FireOnChanged(type, targetObject, dispID); return S_OK; }
void Mesh::SetVertices(const Math::VectorArray<3, float>& verts) { if (count == 0) count = verts.Length(); #if ZEUS_SAFE if (verts.Length() != count) throw Exception("Length of vertex list does not match the size of the mesh."); #endif this->verts = verts; CalculateBounds(); }
void gfx_light::AddToTable() { LineCollideStar tmp; bool err; LineCollide * coltarg= new LineCollide (CalculateBounds(err));//leak?? if (err) return; tmp.lc = coltarg; lighttable.Put (coltarg, tmp); }
///////////////////////////////////////////////////////////////////////////// // MFCInstanceView ///////////////////////////////////////////////////////////////////////////// MFCInstanceView::MFCInstanceView(Instance *i, MFCArrangeView *a) // : MFCEditorItemView(NULL, INSTANCE) { instance = i; arranger = a; selected = false; CalculateBounds(); // Redraw(); }
STDMETHODIMP CPDObjectSymbolInstance::setxy(double x, double y) { m_x = x; m_y = y; CalculateBounds(); FireOnChanged(NOTIFY_MODIFY, GetUnknown(), DISPID_UNKNOWN); return S_OK; }
///////////////////////////////////////////////////////////////////////////// // MFCStreamItemView ///////////////////////////////////////////////////////////////////////////// MFCEditorItemView::MFCEditorItemView(MFCSequenceEditor *a, short typ) { editor = a; type = typ; selected = false; // fprintf(stderr, "%s -> ", i->startTime.StringValue()); // fprintf(stderr, "%s\n", arrTime.StringValue()); // fprintf(stderr, "%s -> ", i->duration.StringValue()); // fprintf(stderr, "%s\n", arrDur.StringValue()); CalculateBounds(); // Redraw(); }
void MFCEditorItemView::DrawMove() { if (editor) { CPoint scr = editor->GetScrollPosition(); CRect oldr = bounds - scr; oldr.right++; oldr.bottom++; CalculateBounds(); editor->InvalidateRect(&oldr); Redraw(); } }
sp<ImageSet> PCKLoader::load_shadow(Data &data, UString PckFilename, UString TabFilename, uint8_t shadedIdx) { TRACE_FN; auto imageSet = mksp<ImageSet>(); auto tabFile = data.fs.open(TabFilename); if (!tabFile) { LogWarning("Failed to open tab \"%s\"", TabFilename.c_str()); return nullptr; } auto pckFile = data.fs.open(PckFilename); if (!pckFile) { LogWarning("Failed to open tab \"%s\"", TabFilename.c_str()); return nullptr; } imageSet->maxSize = {0, 0}; uint32_t offset = 0; unsigned idx = 0; while (tabFile.read(reinterpret_cast<char *>(&offset), sizeof(offset))) { // shadow TAB files store the offset directly pckFile.seekg(offset, std::ios::beg); if (!pckFile) { LogError("Failed to seek to offset %u", offset); return nullptr; } auto img = loadShadow(pckFile, shadedIdx); if (!img) { LogError("Failed to load image"); return nullptr; } imageSet->images.push_back(img); img->owningSet = imageSet; img->CalculateBounds(); img->indexInSet = idx++; if (img->size.x > imageSet->maxSize.x) imageSet->maxSize.x = img->size.x; if (img->size.y > imageSet->maxSize.y) imageSet->maxSize.y = img->size.y; } LogInfo("Loaded %u images", static_cast<unsigned>(imageSet->images.size())); return imageSet; }
void MFCInstanceView::DrawMove() { if (arranger) { CPoint scr = arranger->GetScrollPosition(); CRect oldr = bounds - scr; oldr.right++; oldr.bottom++; CalculateBounds(); arranger->InvalidateRect(&oldr); Redraw(); arranger->UpdateWindow(); } }
sp<ImageSet> PCKLoader::load_strat(Data &data, UString PckFilename, UString TabFilename) { auto imageSet = mksp<ImageSet>(); auto tabFile = data.fs.open(TabFilename); if (!tabFile) { LogWarning("Failed to open tab \"%s\"", TabFilename.c_str()); return nullptr; } auto pckFile = data.fs.open(PckFilename); if (!pckFile) { LogWarning("Failed to open tab \"%s\"", TabFilename.c_str()); return nullptr; } uint32_t offset = 0; unsigned idx = 0; while (tabFile.read(reinterpret_cast<char *>(&offset), sizeof(offset))) { pckFile.seekg(offset, std::ios::beg); if (!pckFile) { LogError("Failed to seek to offset %u", offset); return nullptr; } auto img = loadStrategy(pckFile); if (!img) { LogError("Failed to load image"); return nullptr; } if (img->size != Vec2<unsigned int>{8, 8}) { LogError("Invalid size of {%d,%d} in stratmap image", img->size.x, img->size.y); return nullptr; } imageSet->images.push_back(img); img->owningSet = imageSet; img->CalculateBounds(); img->indexInSet = idx++; } imageSet->maxSize = {8, 8}; LogInfo("Loaded %u images", static_cast<unsigned>(imageSet->images.size())); return imageSet; }
void MFCClipItemView::SetClipStartTime(Time &st) { if (item) { item->start = st; CRect olb = bounds;olb.right = olb.left + 13;olb.left-=1; CRect orb = bounds;orb.left = orb.right - 10;orb.right+=3; CalculateBounds(); CRect nrb = bounds;nrb.left = nrb.right - 10;nrb.right+=3; CRect nlb = bounds;nlb.right = nlb.left + 13;nlb.left-=1; editor->InvalidateRect(&olb); editor->InvalidateRect(&orb); editor->InvalidateRect(&nrb); editor->InvalidateRect(&nlb); } }
STDMETHODIMP CPDObjectFrame::Deserialize(/*[in]*/ IArchive* ar, IArchiveElement* node, IUnknown* pUnkExtra) { HRESULT hr; hr = CPDObjectImpl<IPDObjectFrame>::Deserialize(ar, node, pUnkExtra); if (FAILED(hr)) return hr; hr = CPDObjectTransformableImpl<CPDObjectFrame>::Deserialize(ar, node, pUnkExtra); if (FAILED(hr)) return hr; CPDObjectWithOpacityMaskImpl<CPDObjectFrame>::Deserialize(ar, node, NULL); if (FAILED(hr)) return hr; hr = CPDObjectWithAppearanceAndStrokeFillImpl<CPDObjectFrame>::Deserialize(ar, node, pUnkExtra); if (FAILED(hr)) return hr; CComPtr<IArchiveElement> pathNode; node->getAttributeNode(L"path", &pathNode); if (pathNode) m_path->Deserialize(ar, pathNode, NULL); m_subObjects->m_items.RemoveAll(); CComObject<CObjectMap>* pMap; CComObject<CObjectMap>::CreateInstance(&pMap); if (pMap) { if (SUCCEEDED(node->getObjectMap(L"subObjects", pMap, NULL))) { for (int i = 0; i < pMap->m_items.GetSize(); i++) { IPDObjectWithBrush* p = static_cast<IPDObjectWithBrush*>(pMap->m_items[i]); appendSubObject(p); } } pMap->Release(); } CPDObjectWrappableImpl<CPDObjectFrame>::Deserialize(ar, node, pUnkExtra); if (FAILED(hr)) return hr; CalculateBounds(); return S_OK; }
void MFCClipItemView::SetClipEndTime(Time &et) { if (item) { if (et >item->start) { item->duration = et-item->start; // CRect olb = bounds;olb.right = olb.left + 13;olb.left-=1; CRect orb = bounds;orb.left = orb.right - 10;orb.right+=3; CalculateBounds(); CRect nrb = bounds;nrb.left = nrb.right - 10;nrb.right+=3; // CRect nlb = bounds;nlb.right = nlb.left + 13;nlb.left-=1; // editor->InvalidateRect(&olb); editor->InvalidateRect(&orb); editor->InvalidateRect(&nrb); // editor->InvalidateRect(&nlb); } } }
STDMETHODIMP CPDObjectSymbolInstance::put_symbol(IPDSymbol *newVal) { if (m_symbol) { CComQIPtr<INotifySend> cp = m_symbol; cp->Unadvise(this); } m_symbol = newVal; if (m_symbol) { CComQIPtr<INotifySend> cp = m_symbol; DWORD cookie; cp->Advise(this, &cookie); } CalculateBounds(); return S_OK; }
bool wxSheetSelection::UpdateCols( size_t col, int numCols ) { if (numCols == 0) return false; bool done = false; int n, count = GetCount(); for (n = 0; n < count; n++) { wxSheetBlock &b = m_blocks[n]; done |= b.UpdateCols(col, numCols); if (b.IsEmpty()) { m_blocks.RemoveAt(n); count--; n--; } } CalculateBounds(); return done; }
void AABB2D::SetCenter(const Vec2f ¢er) { m_center = center; CalculateBounds(); }
///////////////////////////////////////////////////////////////////////////// // MFCClipItemView ///////////////////////////////////////////////////////////////////////////// MFCClipItemView::MFCClipItemView(MFCSequenceEditor *ed, Clip *c): MFCEditorItemView(ed, CLIP) { item = c; CalculateBounds(); }
bool wxSheetSelection::DeselectBlock( const wxSheetBlock& block, bool combineNow, wxArraySheetBlock *deletedBlocks ) { int n, count = m_blocks.GetCount(); if ((count == 0) || !m_bounds.Intersects(block)) return false; bool done = false; bool recalc_bounds = false; const int bottom_row = block.GetBottom(); if (deletedBlocks) deletedBlocks->Clear(); wxArraySheetBlock extraBlocks; wxSheetBlock top, bottom, left, right; // iterate though blocks cutting input block out and adding remainder to end for (n=FindTopRow(bottom_row); n<count; n++) { if (bottom_row < m_blocks[n].GetTop()) break; const int deleted = m_blocks[n].Delete(block, top, bottom, left, right); if (deleted != wxSHEET_BLOCK_NONE) { done = true; int last_n = n; if (deletedBlocks) deletedBlocks->Add(m_blocks[n].Intersect(block)); if (m_bounds.SideMatches(m_blocks[n]) != wxSHEET_BLOCK_NONE) recalc_bounds = true; if (m_blocks[n].Contains(block)) n = count + 100; // all done, but add cutouts back else n--; m_blocks.RemoveAt(last_n); count--; if (deleted != wxSHEET_BLOCK_ALL) { if ((deleted & wxSHEET_BLOCK_TOP) != 0) extraBlocks.Add(top); if ((deleted & wxSHEET_BLOCK_BOTTOM) != 0) extraBlocks.Add(bottom); if ((deleted & wxSHEET_BLOCK_LEFT) != 0) extraBlocks.Add(left); if ((deleted & wxSHEET_BLOCK_RIGHT) != 0) extraBlocks.Add(right); } } } if (done) { m_minimized = false; const int extra_count = extraBlocks.GetCount(); for (n=0; n<extra_count; n++) InsertBlock(extraBlocks.Item(n)); if (combineNow) Minimize(); if (recalc_bounds) CalculateBounds(); } return done; }
void wish_mesh::SetVertices(r32* vertices, u32 numVertices) { Vertices = vertices; NumVertices = numVertices; VertexSize = GetVertexSize(MeshType); CalculateBounds(); }
void AABB2D::IncCenter(const Vec2f &increment) { m_center += increment; CalculateBounds(); }
/* ==================== idRenderModelMD5::LoadModel used for initial loads, reloadModel, and reloading the data of purged models Upon exit, the model will absolutely be valid, but possibly as a default model ==================== */ void idRenderModelMD5::LoadModel() { int version; int i; int num; int parentNum; idToken token; idLexer parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS ); idJointQuat *pose; idMD5Joint *joint; idJointMat *poseMat3; if ( !purged ) { PurgeModel(); } purged = false; if ( !parser.LoadFile( name ) ) { MakeDefaultModel(); return; } parser.ExpectTokenString( MD5_VERSION_STRING ); version = parser.ParseInt(); if ( version != MD5_VERSION ) { parser.Error( "Invalid version %d. Should be version %d\n", version, MD5_VERSION ); } // // skip commandline // parser.ExpectTokenString( "commandline" ); parser.ReadToken( &token ); // parse num joints parser.ExpectTokenString( "numJoints" ); num = parser.ParseInt(); joints.SetGranularity( 1 ); joints.SetNum( num ); defaultPose.SetGranularity( 1 ); defaultPose.SetNum( num ); poseMat3 = ( idJointMat * )_alloca16( num * sizeof( *poseMat3 ) ); // parse num meshes parser.ExpectTokenString( "numMeshes" ); num = parser.ParseInt(); if ( num < 0 ) { parser.Error( "Invalid size: %d", num ); } meshes.SetGranularity( 1 ); meshes.SetNum( num ); // // parse joints // parser.ExpectTokenString( "joints" ); parser.ExpectTokenString( "{" ); pose = defaultPose.Ptr(); joint = joints.Ptr(); for( i = 0; i < joints.Num(); i++, joint++, pose++ ) { ParseJoint( parser, joint, pose ); poseMat3[ i ].SetRotation( pose->q.ToMat3() ); poseMat3[ i ].SetTranslation( pose->t ); if ( joint->parent ) { parentNum = joint->parent - joints.Ptr(); pose->q = ( poseMat3[ i ].ToMat3() * poseMat3[ parentNum ].ToMat3().Transpose() ).ToQuat(); pose->t = ( poseMat3[ i ].ToVec3() - poseMat3[ parentNum ].ToVec3() ) * poseMat3[ parentNum ].ToMat3().Transpose(); } } parser.ExpectTokenString( "}" ); for( i = 0; i < meshes.Num(); i++ ) { parser.ExpectTokenString( "mesh" ); meshes[ i ].ParseMesh( parser, defaultPose.Num(), poseMat3 ); } // // calculate the bounds of the model // CalculateBounds( poseMat3 ); // set the timestamp for reloadmodels fileSystem->ReadFile( name, NULL, &timeStamp ); }
void AABB2D::SetHalfDims(const Vec2f &halfDims) { m_halfDims = halfDims; CalculateBounds(); }
//----------------------------------------------------------------------------- void CPUTCheckbox::GetDimensions(int &width, int &height) { CalculateBounds(); width = mControlDimensions.width; height = mControlDimensions.height; }