static BOOLEAN GetFrameValidRect (PRECT pValidRect, HOT_SPOT *pOldHot) { COORD hx, hy; HOT_SPOT OldHot; OldHot = _CurFramePtr->HotSpot; hx = OldHot.x; hy = OldHot.y; pValidRect->corner.x = hx; pValidRect->corner.y = hy; pValidRect->extent.width = GetFrameWidth (_CurFramePtr); pValidRect->extent.height = GetFrameHeight (_CurFramePtr); if (_pCurContext->ClipRect.extent.width) { if (!BoxIntersect (&_pCurContext->ClipRect, pValidRect, pValidRect)) return (FALSE); hx -= _pCurContext->ClipRect.corner.x; hy -= _pCurContext->ClipRect.corner.y; pValidRect->corner.x += hx; pValidRect->corner.y += hy; _CurFramePtr->HotSpot = MAKE_HOT_SPOT (hx, hy); } *pOldHot = OldHot; return (TRUE); }
// 'area' may be NULL to copy the entire CONTEXT cliprect // 'area' is relative to the CONTEXT cliprect DRAWABLE CopyContextRect (const RECT* area) { RECT clipRect; RECT fgRect; RECT r; if (!ContextActive () || !_CurFramePtr) return NULL; fgRect = _get_context_fg_rect (); GetContextClipRect (&clipRect); r = clipRect; if (area) { // a portion of the context r.corner.x += area->corner.x; r.corner.y += area->corner.y; r.extent = area->extent; } // TODO: Should this take CONTEXT origin into account too? // validate the rect if (!BoxIntersect (&r, &fgRect, &r)) return NULL; if (_CurFramePtr->Type == SCREEN_DRAWABLE) return LoadDisplayPixmap (&r, NULL); else return CopyFrameRect (_CurFramePtr, &r); }
// pValidRect or origin may be NULL BOOLEAN GetContextValidRect (RECT *pValidRect, POINT *origin) { RECT tempRect; POINT tempPt; if (!pValidRect) pValidRect = &tempRect; if (!origin) origin = &tempPt; // Start with a rect the size of foreground frame pValidRect->corner.x = 0; pValidRect->corner.y = 0; pValidRect->extent = GetFrameBounds (_CurFramePtr); *origin = _CurFramePtr->HotSpot; if (_pCurContext->ClipRect.extent.width) { // If the cliprect is completely outside of the valid frame // bounds we have nothing to draw if (!BoxIntersect (&_pCurContext->ClipRect, pValidRect, pValidRect)) return (FALSE); // Foreground frame hotspot defines a drawing position offset // WRT the context cliprect origin->x += _pCurContext->ClipRect.corner.x; origin->y += _pCurContext->ClipRect.corner.y; } return (TRUE); }
/** * @brief Clips the specified trace to other solid entities in the frame. */ static void Cl_ClipTraceToEntities(cl_trace_t *trace) { for (uint16_t i = 0; i < cl.frame.num_entities; i++) { const uint32_t snum = (cl.frame.entity_state + i) & ENTITY_STATE_MASK; const entity_state_t *s = &cl.entity_states[snum]; if (s->solid < SOLID_BOX) { continue; } if (s->number == trace->skip) { continue; } const cl_entity_t *ent = &cl.entities[s->number]; if (ent == cl.entity) { continue; } if (!BoxIntersect(ent->abs_mins, ent->abs_maxs, trace->box_mins, trace->box_maxs)) { continue; } const int32_t head_node = Cl_HullForEntity(s); cm_trace_t tr = Cm_TransformedBoxTrace(trace->start, trace->end, trace->mins, trace->maxs, head_node, trace->contents, &ent->matrix, &ent->inverse_matrix); if (tr.start_solid || tr.fraction < trace->trace.fraction) { trace->trace = tr; trace->trace.ent = (struct g_entity_s *) (ptrdiff_t) s->number; if (tr.start_solid) { return; } } } }
/** * @brief */ static void Sv_BoxEntities_r(sv_sector_t *sector) { GList *e = sector->entities; while (e) { g_entity_t *ent = (g_entity_t *) e->data; if (Sv_BoxEntities_Filter(ent)) { if (BoxIntersect(ent->abs_mins, ent->abs_maxs, sv_world.box_mins, sv_world.box_maxs)) { sv_world.box_entities[sv_world.num_box_entities] = ent; sv_world.num_box_entities++; if (sv_world.num_box_entities == sv_world.max_box_entities) { Com_Warn("sv_world.max_box_entities reached\n"); return; } } } e = e->next; } if (sector->axis == -1) { return; // terminal node } // recurse down both sides if (sv_world.box_maxs[sector->axis] > sector->dist) { Sv_BoxEntities_r(sector->children[0]); } if (sv_world.box_mins[sector->axis] < sector->dist) { Sv_BoxEntities_r(sector->children[1]); } }