Blender  V3.3
GHOST_Rect.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include "GHOST_Rect.h"
9 
11 {
12  if (i > 0) {
13  /* Grow the rectangle. */
14  m_l -= i;
15  m_r += i;
16  m_t -= i;
17  m_b += i;
18  }
19  else if (i < 0) {
20  /* Shrink the rectangle, check for insets larger than half the size. */
21  int32_t i2 = i * 2;
22  if (getWidth() > i2) {
23  m_l += i;
24  m_r -= i;
25  }
26  else {
27  m_l = m_l + ((m_r - m_l) / 2);
28  m_r = m_l;
29  }
30  if (getHeight() > i2) {
31  m_t += i;
32  m_b -= i;
33  }
34  else {
35  m_t = m_t + ((m_b - m_t) / 2);
36  m_b = m_t;
37  }
38  }
39 }
40 
42 {
43  bool lt = isInside(r.m_l, r.m_t);
44  bool rt = isInside(r.m_r, r.m_t);
45  bool lb = isInside(r.m_l, r.m_b);
46  bool rb = isInside(r.m_r, r.m_b);
48  if (lt && rt && lb && rb) {
49  /* All points inside, rectangle is inside this. */
51  }
52  else if (!(lt || rt || lb || rb)) {
53  /* None of the points inside.
54  * Check to see whether the rectangle is larger than this one. */
55  if ((r.m_l < m_l) && (r.m_t < m_t) && (r.m_r > m_r) && (r.m_b > m_b)) {
57  }
58  else {
60  }
61  }
62  else {
63  /* Some of the points inside, rectangle is partially inside. */
65  }
66  return v;
67 }
68 
70 {
71  int32_t offset = cx - (m_l + (m_r - m_l) / 2);
72  m_l += offset;
73  m_r += offset;
74  offset = cy - (m_t + (m_b - m_t) / 2);
75  m_t += offset;
76  m_b += offset;
77 }
78 
80 {
81  long w_2, h_2;
82 
83  w_2 = w >> 1;
84  h_2 = h >> 1;
85  m_l = cx - w_2;
86  m_t = cy - h_2;
87  m_r = m_l + w;
88  m_b = m_t + h;
89 }
90 
92 {
93  bool clipped = false;
94  if (r.m_l < m_l) {
95  r.m_l = m_l;
96  clipped = true;
97  }
98  if (r.m_t < m_t) {
99  r.m_t = m_t;
100  clipped = true;
101  }
102  if (r.m_r > m_r) {
103  r.m_r = m_r;
104  clipped = true;
105  }
106  if (r.m_b > m_b) {
107  r.m_b = m_b;
108  clipped = true;
109  }
110  return clipped;
111 }
GHOST_TVisibility
Definition: GHOST_Types.h:110
@ GHOST_kFullyVisible
Definition: GHOST_Types.h:113
@ GHOST_kPartiallyVisible
Definition: GHOST_Types.h:112
@ GHOST_kNotVisible
Definition: GHOST_Types.h:111
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
virtual GHOST_TVisibility getVisibility(GHOST_Rect &r) const
Definition: GHOST_Rect.cpp:41
virtual void inset(int32_t i)
Definition: GHOST_Rect.cpp:10
virtual bool isInside(int32_t x, int32_t y) const
Definition: GHOST_Rect.h:274
int32_t m_l
Definition: GHOST_Rect.h:156
virtual bool clip(GHOST_Rect &r) const
Definition: GHOST_Rect.cpp:91
virtual void setCenter(int32_t cx, int32_t cy)
Definition: GHOST_Rect.cpp:69
int32_t m_r
Definition: GHOST_Rect.h:160
int32_t m_b
Definition: GHOST_Rect.h:162
virtual int32_t getHeight() const
Definition: GHOST_Rect.h:174
int32_t m_t
Definition: GHOST_Rect.h:158
virtual int32_t getWidth() const
Definition: GHOST_Rect.h:169
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
signed int int32_t
Definition: stdint.h:77