transformState.I 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  1. // Filename: transformState.I
  2. // Created by: drose (25Feb02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: TransformState::operator <
  16. // Access: Published
  17. // Description: Provides an arbitrary ordering among all unique
  18. // TransformStates, so we can store the essentially
  19. // different ones in a big set and throw away the rest.
  20. //
  21. // This is the same as sorts_less(), except the
  22. // uniquify_matrix value is implicit from the Config.prc
  23. // file.
  24. ////////////////////////////////////////////////////////////////////
  25. INLINE bool TransformState::
  26. operator < (const TransformState &other) const {
  27. return sorts_less(other, uniquify_matrix);
  28. }
  29. ////////////////////////////////////////////////////////////////////
  30. // Function: TransformState::get_hash
  31. // Access: Published
  32. // Description: Returns a suitable hash value for phash_map.
  33. ////////////////////////////////////////////////////////////////////
  34. INLINE size_t TransformState::
  35. get_hash() const {
  36. check_hash();
  37. return _hash;
  38. }
  39. ////////////////////////////////////////////////////////////////////
  40. // Function: TransformState::make_pos
  41. // Access: Published, Static
  42. // Description: Makes a new TransformState with the specified
  43. // components.
  44. ////////////////////////////////////////////////////////////////////
  45. INLINE CPT(TransformState) TransformState::
  46. make_pos(const LVecBase3f &pos) {
  47. return make_pos_hpr_scale(pos,
  48. LVecBase3f(0.0f, 0.0f, 0.0f),
  49. LVecBase3f(1.0f, 1.0f, 1.0f));
  50. }
  51. ////////////////////////////////////////////////////////////////////
  52. // Function: TransformState::make_hpr
  53. // Access: Published, Static
  54. // Description: Makes a new TransformState with the specified
  55. // components.
  56. ////////////////////////////////////////////////////////////////////
  57. INLINE CPT(TransformState) TransformState::
  58. make_hpr(const LVecBase3f &hpr) {
  59. return make_pos_hpr_scale(LVecBase3f(0.0f, 0.0f, 0.0f),
  60. hpr,
  61. LVecBase3f(1.0f, 1.0f, 1.0f));
  62. }
  63. ////////////////////////////////////////////////////////////////////
  64. // Function: TransformState::make_quat
  65. // Access: Published, Static
  66. // Description: Makes a new TransformState with the specified
  67. // components.
  68. ////////////////////////////////////////////////////////////////////
  69. INLINE CPT(TransformState) TransformState::
  70. make_quat(const LQuaternionf &quat) {
  71. return make_pos_quat_scale(LVecBase3f(0.0f, 0.0f, 0.0f),
  72. quat,
  73. LVecBase3f(1.0f, 1.0f, 1.0f));
  74. }
  75. ////////////////////////////////////////////////////////////////////
  76. // Function: TransformState::make_pos_hpr
  77. // Access: Published, Static
  78. // Description: Makes a new TransformState with the specified
  79. // components.
  80. ////////////////////////////////////////////////////////////////////
  81. INLINE CPT(TransformState) TransformState::
  82. make_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) {
  83. return make_pos_hpr_scale(pos, hpr,
  84. LVecBase3f(1.0, 1.0f, 1.0f));
  85. }
  86. ////////////////////////////////////////////////////////////////////
  87. // Function: TransformState::make_scale
  88. // Access: Published, Static
  89. // Description: Makes a new TransformState with the specified
  90. // components.
  91. ////////////////////////////////////////////////////////////////////
  92. INLINE CPT(TransformState) TransformState::
  93. make_scale(float scale) {
  94. // We actually map this 3-d uniform make_scale() to the 2-d
  95. // version--might as well call it a 2-d scale.
  96. return make_scale2d(scale);
  97. }
  98. ////////////////////////////////////////////////////////////////////
  99. // Function: TransformState::make_scale
  100. // Access: Published, Static
  101. // Description: Makes a new TransformState with the specified
  102. // components.
  103. ////////////////////////////////////////////////////////////////////
  104. INLINE CPT(TransformState) TransformState::
  105. make_scale(const LVecBase3f &scale) {
  106. return make_pos_hpr_scale(LVecBase3f(0.0f, 0.0f, 0.0f),
  107. LVecBase3f(0.0f, 0.0f, 0.0f),
  108. scale);
  109. }
  110. ////////////////////////////////////////////////////////////////////
  111. // Function: TransformState::make_shear
  112. // Access: Published, Static
  113. // Description: Makes a new TransformState with the specified
  114. // components.
  115. ////////////////////////////////////////////////////////////////////
  116. INLINE CPT(TransformState) TransformState::
  117. make_shear(const LVecBase3f &shear) {
  118. return make_pos_hpr_scale_shear(LVecBase3f(0.0f, 0.0f, 0.0f),
  119. LVecBase3f(0.0f, 0.0f, 0.0f),
  120. LVecBase3f(1.0f, 1.0f, 1.0f),
  121. shear);
  122. }
  123. ////////////////////////////////////////////////////////////////////
  124. // Function: TransformState::make_pos_hpr_scale
  125. // Access: Published, Static
  126. // Description: Makes a new TransformState with the specified
  127. // components.
  128. ////////////////////////////////////////////////////////////////////
  129. INLINE CPT(TransformState) TransformState::
  130. make_pos_hpr_scale(const LVecBase3f &pos, const LVecBase3f &hpr,
  131. const LVecBase3f &scale) {
  132. return make_pos_hpr_scale_shear(pos, hpr, scale, LVecBase3f::zero());
  133. }
  134. ////////////////////////////////////////////////////////////////////
  135. // Function: TransformState::make_pos_quat_scale
  136. // Access: Published, Static
  137. // Description: Makes a new TransformState with the specified
  138. // components.
  139. ////////////////////////////////////////////////////////////////////
  140. INLINE CPT(TransformState) TransformState::
  141. make_pos_quat_scale(const LVecBase3f &pos, const LQuaternionf &quat,
  142. const LVecBase3f &scale) {
  143. return make_pos_quat_scale_shear(pos, quat, scale, LVecBase3f::zero());
  144. }
  145. ////////////////////////////////////////////////////////////////////
  146. // Function: TransformState::make_pos2d
  147. // Access: Published, Static
  148. // Description: Makes a new 2-d TransformState with the specified
  149. // components.
  150. ////////////////////////////////////////////////////////////////////
  151. INLINE CPT(TransformState) TransformState::
  152. make_pos2d(const LVecBase2f &pos) {
  153. return make_pos_rotate_scale2d(pos, 0.0f, LVecBase2f(1.0f, 1.0f));
  154. }
  155. ////////////////////////////////////////////////////////////////////
  156. // Function: TransformState::make_rotate2d
  157. // Access: Published, Static
  158. // Description: Makes a new 2-d TransformState with the specified
  159. // components.
  160. ////////////////////////////////////////////////////////////////////
  161. INLINE CPT(TransformState) TransformState::
  162. make_rotate2d(float rotate) {
  163. return make_pos_rotate_scale2d(LVecBase2f(0.0f, 0.0f), rotate,
  164. LVecBase2f(1.0f, 1.0f));
  165. }
  166. ////////////////////////////////////////////////////////////////////
  167. // Function: TransformState::make_pos_rotate2d
  168. // Access: Published, Static
  169. // Description: Makes a new 2-d TransformState with the specified
  170. // components.
  171. ////////////////////////////////////////////////////////////////////
  172. INLINE CPT(TransformState) TransformState::
  173. make_pos_rotate2d(const LVecBase2f &pos, float rotate) {
  174. return make_pos_rotate_scale2d(pos, rotate,
  175. LVecBase2f(1.0, 1.0f));
  176. }
  177. ////////////////////////////////////////////////////////////////////
  178. // Function: TransformState::make_scale2d
  179. // Access: Published, Static
  180. // Description: Makes a new 2-d TransformState with the specified
  181. // components.
  182. ////////////////////////////////////////////////////////////////////
  183. INLINE CPT(TransformState) TransformState::
  184. make_scale2d(float scale) {
  185. return make_pos_rotate_scale2d(LVecBase2f(0.0f, 0.0f), 0.0f,
  186. LVecBase2f(scale, scale));
  187. }
  188. ////////////////////////////////////////////////////////////////////
  189. // Function: TransformState::make_scale2d
  190. // Access: Published, Static
  191. // Description: Makes a new 2-d TransformState with the specified
  192. // components.
  193. ////////////////////////////////////////////////////////////////////
  194. INLINE CPT(TransformState) TransformState::
  195. make_scale2d(const LVecBase2f &scale) {
  196. return make_pos_rotate_scale2d(LVecBase2f(0.0f, 0.0f), 0.0f, scale);
  197. }
  198. ////////////////////////////////////////////////////////////////////
  199. // Function: TransformState::make_shear2d
  200. // Access: Published, Static
  201. // Description: Makes a new 2-d TransformState with the specified
  202. // components.
  203. ////////////////////////////////////////////////////////////////////
  204. INLINE CPT(TransformState) TransformState::
  205. make_shear2d(float shear) {
  206. return make_pos_rotate_scale_shear2d(LVecBase2f(0.0f, 0.0f), 0.0f,
  207. LVecBase2f(1.0f, 1.0f), shear);
  208. }
  209. ////////////////////////////////////////////////////////////////////
  210. // Function: TransformState::make_pos_rotate_scale2d
  211. // Access: Published, Static
  212. // Description: Makes a new 2-d TransformState with the specified
  213. // components.
  214. ////////////////////////////////////////////////////////////////////
  215. INLINE CPT(TransformState) TransformState::
  216. make_pos_rotate_scale2d(const LVecBase2f &pos, float rotate,
  217. const LVecBase2f &scale) {
  218. return make_pos_rotate_scale_shear2d(pos, rotate, scale, 0.0f);
  219. }
  220. ////////////////////////////////////////////////////////////////////
  221. // Function: TransformState::is_identity
  222. // Access: Published
  223. // Description: Returns true if the transform represents the identity
  224. // matrix, false otherwise.
  225. ////////////////////////////////////////////////////////////////////
  226. INLINE bool TransformState::
  227. is_identity() const {
  228. return ((_flags & F_is_identity) != 0);
  229. }
  230. ////////////////////////////////////////////////////////////////////
  231. // Function: TransformState::is_invalid
  232. // Access: Published
  233. // Description: Returns true if the transform represents an invalid
  234. // matrix, for instance the result of inverting a
  235. // singular matrix, or false if the transform is valid.
  236. ////////////////////////////////////////////////////////////////////
  237. INLINE bool TransformState::
  238. is_invalid() const {
  239. return ((_flags & F_is_invalid) != 0);
  240. }
  241. ////////////////////////////////////////////////////////////////////
  242. // Function: TransformState::is_singular
  243. // Access: Published
  244. // Description: Returns true if the transform represents a singular
  245. // transform (that is, it has a zero scale, and it
  246. // cannot be inverted), or false otherwise.
  247. ////////////////////////////////////////////////////////////////////
  248. INLINE bool TransformState::
  249. is_singular() const {
  250. check_singular();
  251. return ((_flags & F_is_singular) != 0);
  252. }
  253. ////////////////////////////////////////////////////////////////////
  254. // Function: TransformState::is_2d
  255. // Access: Published
  256. // Description: Returns true if the transform has been constructed
  257. // entirely using the 2-d transform operations,
  258. // e.g. make_pos2d(), and therefore operates strictly in
  259. // two-dimensional space on X and Y only.
  260. ////////////////////////////////////////////////////////////////////
  261. INLINE bool TransformState::
  262. is_2d() const {
  263. return ((_flags & F_is_2d) != 0);
  264. }
  265. ////////////////////////////////////////////////////////////////////
  266. // Function: TransformState::has_components
  267. // Access: Published
  268. // Description: Returns true if the transform can be described by
  269. // separate pos, hpr, and scale components. Most
  270. // transforms we use in everyday life can be so
  271. // described, but some kinds of transforms (for
  272. // instance, those involving a skew) cannot.
  273. //
  274. // This is not related to whether the transform was
  275. // originally described componentwise. Even a transform
  276. // that was constructed with a 4x4 may return true here
  277. // if the matrix is a simple affine matrix with no skew.
  278. //
  279. // If this returns true, you may safely call get_hpr()
  280. // and get_scale() to retrieve the components. (You
  281. // may always safely call get_pos() whether this returns
  282. // true or false.)
  283. ////////////////////////////////////////////////////////////////////
  284. INLINE bool TransformState::
  285. has_components() const {
  286. check_components();
  287. return ((_flags & F_has_components) != 0);
  288. }
  289. ////////////////////////////////////////////////////////////////////
  290. // Function: TransformState::components_given
  291. // Access: Published
  292. // Description: Returns true if the transform was specified
  293. // componentwise, or false if it was specified with a
  294. // general 4x4 matrix. If this is true, the components
  295. // returned by get_pos() and get_scale() will be exactly
  296. // those that were set; otherwise, these functions will
  297. // return computed values. If this is true, the
  298. // rotation may have been set either with a hpr trio or
  299. // with a quaternion; hpr_given() or quat_given() can
  300. // resolve the difference.
  301. ////////////////////////////////////////////////////////////////////
  302. INLINE bool TransformState::
  303. components_given() const {
  304. return ((_flags & F_components_given) != 0);
  305. }
  306. ////////////////////////////////////////////////////////////////////
  307. // Function: TransformState::hpr_given
  308. // Access: Published
  309. // Description: Returns true if the rotation was specified via a trio
  310. // of Euler angles, false otherwise. If this is true,
  311. // get_hpr() will be exactly as set; otherwise, it will
  312. // return a computed value.
  313. ////////////////////////////////////////////////////////////////////
  314. INLINE bool TransformState::
  315. hpr_given() const {
  316. return ((_flags & F_hpr_given) != 0);
  317. }
  318. ////////////////////////////////////////////////////////////////////
  319. // Function: TransformState::quat_given
  320. // Access: Published
  321. // Description: Returns true if the rotation was specified via a
  322. // quaternion, false otherwise. If this is true,
  323. // get_quat() will be exactly as set; otherwise, it will
  324. // return a computed value.
  325. ////////////////////////////////////////////////////////////////////
  326. INLINE bool TransformState::
  327. quat_given() const {
  328. return ((_flags & F_quat_given) != 0);
  329. }
  330. ////////////////////////////////////////////////////////////////////
  331. // Function: TransformState::has_pos
  332. // Access: Published
  333. // Description: Returns true if the transform's pos component can be
  334. // extracted out separately. This is generally always
  335. // true, unless the transform is invalid
  336. // (i.e. is_invalid() returns true).
  337. ////////////////////////////////////////////////////////////////////
  338. INLINE bool TransformState::
  339. has_pos() const {
  340. return !is_invalid();
  341. }
  342. ////////////////////////////////////////////////////////////////////
  343. // Function: TransformState::has_hpr
  344. // Access: Published
  345. // Description: Returns true if the transform's rotation component
  346. // can be extracted out separately and described as a
  347. // set of Euler angles. This is generally true only
  348. // when has_components() is true.
  349. ////////////////////////////////////////////////////////////////////
  350. INLINE bool TransformState::
  351. has_hpr() const {
  352. return has_components();
  353. }
  354. ////////////////////////////////////////////////////////////////////
  355. // Function: TransformState::has_quat
  356. // Access: Published
  357. // Description: Returns true if the transform's rotation component
  358. // can be extracted out separately and described as a
  359. // quaternion. This is generally true only when
  360. // has_components() is true.
  361. ////////////////////////////////////////////////////////////////////
  362. INLINE bool TransformState::
  363. has_quat() const {
  364. return has_components();
  365. }
  366. ////////////////////////////////////////////////////////////////////
  367. // Function: TransformState::has_scale
  368. // Access: Published
  369. // Description: Returns true if the transform's scale component
  370. // can be extracted out separately. This is generally
  371. // true only when has_components() is true.
  372. ////////////////////////////////////////////////////////////////////
  373. INLINE bool TransformState::
  374. has_scale() const {
  375. return has_components();
  376. }
  377. ////////////////////////////////////////////////////////////////////
  378. // Function: TransformState::has_identity_scale
  379. // Access: Published
  380. // Description: Returns true if the scale is uniform 1.0, or false if
  381. // the scale has some real value.
  382. ////////////////////////////////////////////////////////////////////
  383. INLINE bool TransformState::
  384. has_identity_scale() const {
  385. check_components();
  386. return (_flags & F_identity_scale) != 0;
  387. }
  388. ////////////////////////////////////////////////////////////////////
  389. // Function: TransformState::has_uniform_scale
  390. // Access: Published
  391. // Description: Returns true if the scale is uniform across all three
  392. // axes (and therefore can be expressed as a single
  393. // number), or false if the transform has a different
  394. // scale in different dimensions.
  395. ////////////////////////////////////////////////////////////////////
  396. INLINE bool TransformState::
  397. has_uniform_scale() const {
  398. check_components();
  399. return (_flags & F_uniform_scale) != 0;
  400. }
  401. ////////////////////////////////////////////////////////////////////
  402. // Function: TransformState::has_shear
  403. // Access: Published
  404. // Description: Returns true if the transform's shear component
  405. // can be extracted out separately. This is generally
  406. // true only when has_components() is true.
  407. ////////////////////////////////////////////////////////////////////
  408. INLINE bool TransformState::
  409. has_shear() const {
  410. return has_components();
  411. }
  412. ////////////////////////////////////////////////////////////////////
  413. // Function: TransformState::has_nonzero_shear
  414. // Access: Published
  415. // Description: Returns true if the shear component is non-zero,
  416. // false if it is zero or if the matrix cannot be
  417. // decomposed.
  418. ////////////////////////////////////////////////////////////////////
  419. INLINE bool TransformState::
  420. has_nonzero_shear() const {
  421. check_components();
  422. return (_flags & F_has_nonzero_shear) != 0;
  423. }
  424. ////////////////////////////////////////////////////////////////////
  425. // Function: TransformState::has_mat
  426. // Access: Published
  427. // Description: Returns true if the transform can be described as a
  428. // matrix. This is generally always true, unless
  429. // is_invalid() is true.
  430. ////////////////////////////////////////////////////////////////////
  431. INLINE bool TransformState::
  432. has_mat() const {
  433. return !is_invalid();
  434. }
  435. ////////////////////////////////////////////////////////////////////
  436. // Function: TransformState::get_pos
  437. // Access: Published
  438. // Description: Returns the pos component of the transform. It is an
  439. // error to call this if has_pos() returned false.
  440. ////////////////////////////////////////////////////////////////////
  441. INLINE const LPoint3f &TransformState::
  442. get_pos() const {
  443. check_components();
  444. nassertr(has_pos(), _pos);
  445. return _pos;
  446. }
  447. ////////////////////////////////////////////////////////////////////
  448. // Function: TransformState::get_hpr
  449. // Access: Published
  450. // Description: Returns the rotation component of the transform as a
  451. // trio of Euler angles. It is an error to call this if
  452. // has_components() returned false.
  453. ////////////////////////////////////////////////////////////////////
  454. INLINE const LVecBase3f &TransformState::
  455. get_hpr() const {
  456. check_hpr();
  457. nassertr(!is_invalid(), _hpr);
  458. return _hpr;
  459. }
  460. ////////////////////////////////////////////////////////////////////
  461. // Function: TransformState::get_quat
  462. // Access: Published
  463. // Description: Returns the rotation component of the transform as a
  464. // quaternion. The return value will be normalized if a
  465. // normalized quaternion was given to the constructor
  466. // (or if the quaternion was computed implicitly); it
  467. // will be non-normalized if a non-normalized quaternion
  468. // was given to the constructor. See also
  469. // get_norm_quat().
  470. //
  471. // It is an error to call this if has_components()
  472. // returned false.
  473. ////////////////////////////////////////////////////////////////////
  474. INLINE const LQuaternionf &TransformState::
  475. get_quat() const {
  476. check_quat();
  477. nassertr(!is_invalid(), _quat);
  478. return _quat;
  479. }
  480. ////////////////////////////////////////////////////////////////////
  481. // Function: TransformState::get_norm_quat
  482. // Access: Published
  483. // Description: Returns the rotation component of the transform as a
  484. // quaternion. Unlike the result of get_quat(), the
  485. // return value of this method is guaranteed to be
  486. // normalized. It is an error to call this if
  487. // has_components() returned false.
  488. ////////////////////////////////////////////////////////////////////
  489. INLINE const LQuaternionf &TransformState::
  490. get_norm_quat() const {
  491. check_norm_quat();
  492. nassertr(!is_invalid(), _norm_quat);
  493. return _norm_quat;
  494. }
  495. ////////////////////////////////////////////////////////////////////
  496. // Function: TransformState::get_scale
  497. // Access: Published
  498. // Description: Returns the scale component of the transform. It is an
  499. // error to call this if has_components() returned
  500. // false.
  501. ////////////////////////////////////////////////////////////////////
  502. INLINE const LVecBase3f &TransformState::
  503. get_scale() const {
  504. check_components();
  505. nassertr(!is_invalid(), _scale);
  506. return _scale;
  507. }
  508. ////////////////////////////////////////////////////////////////////
  509. // Function: TransformState::get_uniform_scale
  510. // Access: Published
  511. // Description: Returns the scale component of the transform, as a
  512. // single number. It is an error to call this if
  513. // has_uniform_scale() returned false.
  514. ////////////////////////////////////////////////////////////////////
  515. INLINE float TransformState::
  516. get_uniform_scale() const {
  517. check_components();
  518. nassertr(has_uniform_scale(), _scale[0]);
  519. return _scale[0];
  520. }
  521. ////////////////////////////////////////////////////////////////////
  522. // Function: TransformState::get_shear
  523. // Access: Published
  524. // Description: Returns the shear component of the transform. It is
  525. // an error to call this if has_components() returned
  526. // false.
  527. ////////////////////////////////////////////////////////////////////
  528. INLINE const LVecBase3f &TransformState::
  529. get_shear() const {
  530. check_components();
  531. nassertr(!is_invalid(), _shear);
  532. return _shear;
  533. }
  534. ////////////////////////////////////////////////////////////////////
  535. // Function: TransformState::get_mat
  536. // Access: Published
  537. // Description: Returns the matrix that describes the transform.
  538. ////////////////////////////////////////////////////////////////////
  539. INLINE const LMatrix4f &TransformState::
  540. get_mat() const {
  541. nassertr(has_mat(), LMatrix4f::ident_mat());
  542. check_mat();
  543. return _mat;
  544. }
  545. ////////////////////////////////////////////////////////////////////
  546. // Function: TransformState::get_pos2d
  547. // Access: Published
  548. // Description: Returns the pos component of the 2-d transform. It
  549. // is an error to call this if has_pos() or is_2d()
  550. // returned false.
  551. ////////////////////////////////////////////////////////////////////
  552. INLINE LVecBase2f TransformState::
  553. get_pos2d() const {
  554. check_components();
  555. nassertr(has_pos() && is_2d(), LVecBase2f::zero());
  556. return LVecBase2f(_pos[0], _pos[1]);
  557. }
  558. ////////////////////////////////////////////////////////////////////
  559. // Function: TransformState::get_rotate2d
  560. // Access: Published
  561. // Description: Returns the rotation component of the 2-d transform
  562. // as an angle in degrees clockwise about the origin.
  563. // It is an error to call this if has_components() or
  564. // is_2d() returned false.
  565. ////////////////////////////////////////////////////////////////////
  566. INLINE float TransformState::
  567. get_rotate2d() const {
  568. check_hpr();
  569. nassertr(!is_invalid() && is_2d(), 0);
  570. switch (get_default_coordinate_system()) {
  571. default:
  572. case CS_zup_right:
  573. return _hpr[0];
  574. case CS_zup_left:
  575. return -_hpr[0];
  576. case CS_yup_right:
  577. return -_hpr[2];
  578. case CS_yup_left:
  579. return _hpr[2];
  580. }
  581. }
  582. ////////////////////////////////////////////////////////////////////
  583. // Function: TransformState::get_scale2d
  584. // Access: Published
  585. // Description: Returns the scale component of the 2-d transform. It
  586. // is an error to call this if has_components() or
  587. // is_2d() returned false.
  588. ////////////////////////////////////////////////////////////////////
  589. INLINE LVecBase2f TransformState::
  590. get_scale2d() const {
  591. check_components();
  592. nassertr(!is_invalid() && is_2d(), LVecBase2f::zero());
  593. return LVecBase2f(_scale[0], _scale[1]);
  594. }
  595. ////////////////////////////////////////////////////////////////////
  596. // Function: TransformState::get_shear2d
  597. // Access: Published
  598. // Description: Returns the shear component of the 2-d transform. It
  599. // is an error to call this if has_components() or
  600. // is_2d() returned false.
  601. ////////////////////////////////////////////////////////////////////
  602. INLINE float TransformState::
  603. get_shear2d() const {
  604. check_components();
  605. nassertr(!is_invalid() && is_2d(), 0.0f);
  606. return _shear[0];
  607. }
  608. ////////////////////////////////////////////////////////////////////
  609. // Function: TransformState::get_mat3
  610. // Access: Published
  611. // Description: Returns the 3x3 matrix that describes the 2-d
  612. // transform. It is an error to call this if is_2d()
  613. // returned false.
  614. ////////////////////////////////////////////////////////////////////
  615. INLINE LMatrix3f TransformState::
  616. get_mat3() const {
  617. nassertr(has_mat() && is_2d(), LMatrix3f::ident_mat());
  618. check_mat();
  619. return LMatrix3f(_mat(0, 0), _mat(0, 1), _mat(0, 3),
  620. _mat(1, 0), _mat(1, 1), _mat(1, 3),
  621. _mat(3, 0), _mat(3, 1), _mat(3, 3));
  622. }
  623. ////////////////////////////////////////////////////////////////////
  624. // Function: TransformState::get_inverse
  625. // Access: Published
  626. // Description: Returns the inverse of this transform. If you are
  627. // going to immediately compose this result with another
  628. // TransformState, it is faster to do it in one
  629. // operation with invert_compose().
  630. ////////////////////////////////////////////////////////////////////
  631. INLINE CPT(TransformState) TransformState::
  632. get_inverse() const {
  633. return invert_compose(TransformState::make_identity());
  634. }
  635. ////////////////////////////////////////////////////////////////////
  636. // Function: TransformState::get_unique
  637. // Access: Published
  638. // Description: Returns the pointer to the unique TransformState in
  639. // the cache that is equivalent to this one. This may
  640. // be the same pointer as this object, or it may be a
  641. // different pointer; but it will be an equivalent
  642. // object, and it will be a shared pointer. This may be
  643. // called from time to time to improve cache benefits.
  644. ////////////////////////////////////////////////////////////////////
  645. INLINE CPT(TransformState) TransformState::
  646. get_unique() const {
  647. return return_unique((TransformState *)this);
  648. }
  649. ////////////////////////////////////////////////////////////////////
  650. // Function: TransformState::get_geom_rendering
  651. // Access: Published
  652. // Description: Returns the union of the Geom::GeomRendering bits
  653. // that will be required once this TransformState is
  654. // applied to a geom which includes the indicated
  655. // geom_rendering bits. The RenderState's
  656. // get_geom_rendering() should already have been
  657. // applied.
  658. ////////////////////////////////////////////////////////////////////
  659. INLINE int TransformState::
  660. get_geom_rendering(int geom_rendering) const {
  661. if ((geom_rendering & GeomEnums::GR_point_perspective) != 0) {
  662. if (!has_identity_scale()) {
  663. geom_rendering |= GeomEnums::GR_point_scale;
  664. }
  665. }
  666. return geom_rendering;
  667. }
  668. ////////////////////////////////////////////////////////////////////
  669. // Function: TransformState::cache_ref
  670. // Access: Published
  671. // Description: Overrides this method to update PStats appropriately.
  672. ////////////////////////////////////////////////////////////////////
  673. INLINE void TransformState::
  674. cache_ref() const {
  675. #ifdef DO_PSTATS
  676. int old_referenced_bits = get_referenced_bits();
  677. NodeCachedReferenceCount::cache_ref();
  678. consider_update_pstats(old_referenced_bits);
  679. #else // DO_PSTATS
  680. NodeCachedReferenceCount::cache_ref();
  681. #endif // DO_PSTATS
  682. }
  683. ////////////////////////////////////////////////////////////////////
  684. // Function: TransformState::cache_unref
  685. // Access: Published
  686. // Description: Overrides this method to update PStats appropriately.
  687. ////////////////////////////////////////////////////////////////////
  688. INLINE bool TransformState::
  689. cache_unref() const {
  690. #ifdef DO_PSTATS
  691. int old_referenced_bits = get_referenced_bits();
  692. bool result = do_cache_unref();
  693. consider_update_pstats(old_referenced_bits);
  694. return result;
  695. #else // DO_PSTATS
  696. return do_cache_unref();
  697. #endif // DO_PSTATS
  698. }
  699. ////////////////////////////////////////////////////////////////////
  700. // Function: TransformState::node_ref
  701. // Access: Published
  702. // Description: Overrides this method to update PStats appropriately.
  703. ////////////////////////////////////////////////////////////////////
  704. INLINE void TransformState::
  705. node_ref() const {
  706. #ifdef DO_PSTATS
  707. int old_referenced_bits = get_referenced_bits();
  708. NodeCachedReferenceCount::node_ref();
  709. consider_update_pstats(old_referenced_bits);
  710. #else // DO_PSTATS
  711. NodeCachedReferenceCount::node_ref();
  712. #endif // DO_PSTATS
  713. }
  714. ////////////////////////////////////////////////////////////////////
  715. // Function: TransformState::node_unref
  716. // Access: Published
  717. // Description: Overrides this method to update PStats appropriately.
  718. ////////////////////////////////////////////////////////////////////
  719. INLINE bool TransformState::
  720. node_unref() const {
  721. #ifdef DO_PSTATS
  722. int old_referenced_bits = get_referenced_bits();
  723. bool result = do_node_unref();
  724. consider_update_pstats(old_referenced_bits);
  725. return result;
  726. #else // DO_PSTATS
  727. return do_node_unref();
  728. #endif // DO_PSTATS
  729. }
  730. ////////////////////////////////////////////////////////////////////
  731. // Function: TransformState::get_composition_cache_num_entries
  732. // Access: Published
  733. // Description: Returns the number of entries in the composition
  734. // cache for this TransformState. This is the number of
  735. // other TransformStates whose composition with this one
  736. // has been cached. This number is not useful for any
  737. // practical reason other than performance analysis.
  738. ////////////////////////////////////////////////////////////////////
  739. INLINE int TransformState::
  740. get_composition_cache_num_entries() const {
  741. LightReMutexHolder holder(*_states_lock);
  742. return _composition_cache.get_num_entries();
  743. }
  744. ////////////////////////////////////////////////////////////////////
  745. // Function: TransformState::get_invert_composition_cache_num_entries
  746. // Access: Published
  747. // Description: Returns the number of entries in the
  748. // invert_composition cache for this TransformState.
  749. // This is similar to the composition cache, but it
  750. // records cache entries for the invert_compose()
  751. // operation. See get_composition_cache_num_entries().
  752. ////////////////////////////////////////////////////////////////////
  753. INLINE int TransformState::
  754. get_invert_composition_cache_num_entries() const {
  755. LightReMutexHolder holder(*_states_lock);
  756. return _invert_composition_cache.get_num_entries();
  757. }
  758. ////////////////////////////////////////////////////////////////////
  759. // Function: TransformState::get_composition_cache_size
  760. // Access: Published
  761. // Description: Returns the number of slots in the composition
  762. // cache for this TransformState. You may use this as
  763. // an upper bound when walking through all of the
  764. // composition cache results via
  765. // get_composition_cache_source() or result().
  766. //
  767. // This has no practical value other than for examining
  768. // the cache for performance analysis.
  769. ////////////////////////////////////////////////////////////////////
  770. INLINE int TransformState::
  771. get_composition_cache_size() const {
  772. LightReMutexHolder holder(*_states_lock);
  773. return _composition_cache.get_size();
  774. }
  775. ////////////////////////////////////////////////////////////////////
  776. // Function: TransformState::get_composition_cache_source
  777. // Access: Published
  778. // Description: Returns the source TransformState of the nth element
  779. // in the composition cache. Returns NULL if there
  780. // doesn't happen to be an entry in the nth element.
  781. // See get_composition_cache_result().
  782. //
  783. // This has no practical value other than for examining
  784. // the cache for performance analysis.
  785. ////////////////////////////////////////////////////////////////////
  786. INLINE const TransformState *TransformState::
  787. get_composition_cache_source(int n) const {
  788. LightReMutexHolder holder(*_states_lock);
  789. if (!_composition_cache.has_element(n)) {
  790. return NULL;
  791. }
  792. return _composition_cache.get_key(n);
  793. }
  794. ////////////////////////////////////////////////////////////////////
  795. // Function: TransformState::get_composition_cache_result
  796. // Access: Published
  797. // Description: Returns the result TransformState of the nth element
  798. // in the composition cache. Returns NULL if there
  799. // doesn't happen to be an entry in the nth element.
  800. //
  801. // In general,
  802. // a->compose(a->get_composition_cache_source(n)) ==
  803. // a->get_composition_cache_result(n).
  804. //
  805. // This has no practical value other than for examining
  806. // the cache for performance analysis.
  807. ////////////////////////////////////////////////////////////////////
  808. INLINE const TransformState *TransformState::
  809. get_composition_cache_result(int n) const {
  810. LightReMutexHolder holder(*_states_lock);
  811. if (!_composition_cache.has_element(n)) {
  812. return NULL;
  813. }
  814. return _composition_cache.get_data(n)._result;
  815. }
  816. ////////////////////////////////////////////////////////////////////
  817. // Function: TransformState::get_invert_composition_cache_size
  818. // Access: Published
  819. // Description: Returns the number of slots in the composition
  820. // cache for this TransformState. You may use this as
  821. // an upper bound when walking through all of the
  822. // composition cache results via
  823. // get_invert_composition_cache_source() or result().
  824. //
  825. // This has no practical value other than for examining
  826. // the cache for performance analysis.
  827. ////////////////////////////////////////////////////////////////////
  828. INLINE int TransformState::
  829. get_invert_composition_cache_size() const {
  830. LightReMutexHolder holder(*_states_lock);
  831. return _invert_composition_cache.get_size();
  832. }
  833. ////////////////////////////////////////////////////////////////////
  834. // Function: TransformState::get_invert_composition_cache_source
  835. // Access: Published
  836. // Description: Returns the source TransformState of the nth element
  837. // in the invert composition cache. Returns NULL if
  838. // there doesn't happen to be an entry in the nth
  839. // element. See get_invert_composition_cache_result().
  840. //
  841. // This has no practical value other than for examining
  842. // the cache for performance analysis.
  843. ////////////////////////////////////////////////////////////////////
  844. INLINE const TransformState *TransformState::
  845. get_invert_composition_cache_source(int n) const {
  846. LightReMutexHolder holder(*_states_lock);
  847. if (!_invert_composition_cache.has_element(n)) {
  848. return NULL;
  849. }
  850. return _invert_composition_cache.get_key(n);
  851. }
  852. ////////////////////////////////////////////////////////////////////
  853. // Function: TransformState::get_invert_composition_cache_result
  854. // Access: Published
  855. // Description: Returns the result TransformState of the nth element
  856. // in the invert composition cache. Returns NULL if
  857. // there doesn't happen to be an entry in the nth
  858. // element.
  859. //
  860. // In general,
  861. // a->invert_compose(a->get_invert_composition_cache_source(n))
  862. // == a->get_invert_composition_cache_result(n).
  863. //
  864. // This has no practical value other than for examining
  865. // the cache for performance analysis.
  866. ////////////////////////////////////////////////////////////////////
  867. INLINE const TransformState *TransformState::
  868. get_invert_composition_cache_result(int n) const {
  869. LightReMutexHolder holder(*_states_lock);
  870. if (!_invert_composition_cache.has_element(n)) {
  871. return NULL;
  872. }
  873. return _invert_composition_cache.get_data(n)._result;
  874. }
  875. ////////////////////////////////////////////////////////////////////
  876. // Function: TransformState::flush_level
  877. // Access: Public, Static
  878. // Description: Flushes the PStatCollectors used during traversal.
  879. ////////////////////////////////////////////////////////////////////
  880. INLINE void TransformState::
  881. flush_level() {
  882. _node_counter.flush_level();
  883. _cache_counter.flush_level();
  884. }
  885. ////////////////////////////////////////////////////////////////////
  886. // Function: TransformState::do_node_unref
  887. // Access: Private
  888. // Description: Reimplements NodeReferenceCount::node_unref(). We do
  889. // this because we have a non-virtual unref() method.
  890. ////////////////////////////////////////////////////////////////////
  891. INLINE bool TransformState::
  892. do_node_unref() const {
  893. node_unref_only();
  894. return unref();
  895. }
  896. ////////////////////////////////////////////////////////////////////
  897. // Function: TransformState::do_cache_unref
  898. // Access: Private
  899. // Description: Reimplements
  900. // CachedTypedWritableReferenceCount::cache_unref(). We
  901. // do this because we have a non-virtual unref() method.
  902. ////////////////////////////////////////////////////////////////////
  903. INLINE bool TransformState::
  904. do_cache_unref() const {
  905. cache_unref_only();
  906. return unref();
  907. }
  908. ////////////////////////////////////////////////////////////////////
  909. // Function: TransformState::check_hash
  910. // Access: Private
  911. // Description: Ensures that we know the hash value.
  912. ////////////////////////////////////////////////////////////////////
  913. INLINE void TransformState::
  914. check_hash() const {
  915. // This pretends to be a const function, even though it's not,
  916. // because it only updates a transparent cache value.
  917. if ((_flags & F_hash_known) == 0) {
  918. ((TransformState *)this)->calc_hash();
  919. }
  920. }
  921. ////////////////////////////////////////////////////////////////////
  922. // Function: TransformState::check_singular
  923. // Access: Private
  924. // Description: Ensures that we know whether the matrix is singular.
  925. ////////////////////////////////////////////////////////////////////
  926. INLINE void TransformState::
  927. check_singular() const {
  928. // This pretends to be a const function, even though it's not,
  929. // because it only updates a transparent cache value.
  930. if ((_flags & F_singular_known) == 0) {
  931. ((TransformState *)this)->calc_singular();
  932. }
  933. }
  934. ////////////////////////////////////////////////////////////////////
  935. // Function: TransformState::check_components
  936. // Access: Private
  937. // Description: Ensures that we know the components of the transform
  938. // (or that we know they cannot be derived).
  939. ////////////////////////////////////////////////////////////////////
  940. INLINE void TransformState::
  941. check_components() const {
  942. // This pretends to be a const function, even though it's not,
  943. // because it only updates a transparent cache value.
  944. if ((_flags & F_components_known) == 0) {
  945. ((TransformState *)this)->calc_components();
  946. }
  947. }
  948. ////////////////////////////////////////////////////////////////////
  949. // Function: TransformState::check_hpr
  950. // Access: Private
  951. // Description: Ensures that we know the hpr of the transform
  952. // (or that we know they cannot be derived).
  953. ////////////////////////////////////////////////////////////////////
  954. INLINE void TransformState::
  955. check_hpr() const {
  956. // This pretends to be a const function, even though it's not,
  957. // because it only updates a transparent cache value.
  958. if ((_flags & F_hpr_known) == 0) {
  959. ((TransformState *)this)->calc_hpr();
  960. }
  961. }
  962. ////////////////////////////////////////////////////////////////////
  963. // Function: TransformState::check_quat
  964. // Access: Private
  965. // Description: Ensures that we know the quat of the transform
  966. // (or that we know they cannot be derived).
  967. ////////////////////////////////////////////////////////////////////
  968. INLINE void TransformState::
  969. check_quat() const {
  970. // This pretends to be a const function, even though it's not,
  971. // because it only updates a transparent cache value.
  972. if ((_flags & F_quat_known) == 0) {
  973. ((TransformState *)this)->calc_quat();
  974. }
  975. }
  976. ////////////////////////////////////////////////////////////////////
  977. // Function: TransformState::check_norm_quat
  978. // Access: Private
  979. // Description: Ensures that we know the normalized quat of the transform
  980. // (or that we know they cannot be derived).
  981. ////////////////////////////////////////////////////////////////////
  982. INLINE void TransformState::
  983. check_norm_quat() const {
  984. // This pretends to be a const function, even though it's not,
  985. // because it only updates a transparent cache value.
  986. if ((_flags & F_norm_quat_known) == 0) {
  987. ((TransformState *)this)->calc_norm_quat();
  988. }
  989. }
  990. ////////////////////////////////////////////////////////////////////
  991. // Function: TransformState::check_mat
  992. // Access: Private
  993. // Description: Ensures that we know the overall matrix.
  994. ////////////////////////////////////////////////////////////////////
  995. INLINE void TransformState::
  996. check_mat() const {
  997. // This pretends to be a const function, even though it's not,
  998. // because it only updates a transparent cache value.
  999. if ((_flags & F_mat_known) == 0) {
  1000. ((TransformState *)this)->calc_mat();
  1001. }
  1002. }
  1003. ////////////////////////////////////////////////////////////////////
  1004. // Function: TransformState::calc_hash
  1005. // Access: Private
  1006. // Description: Computes the hash value.
  1007. ////////////////////////////////////////////////////////////////////
  1008. INLINE void TransformState::
  1009. calc_hash() {
  1010. LightMutexHolder holder(_lock);
  1011. do_calc_hash();
  1012. }
  1013. ////////////////////////////////////////////////////////////////////
  1014. // Function: TransformState::calc_components
  1015. // Access: Private
  1016. // Description: Derives the components from the matrix, if possible.
  1017. ////////////////////////////////////////////////////////////////////
  1018. INLINE void TransformState::
  1019. calc_components() {
  1020. LightMutexHolder holder(_lock);
  1021. do_calc_components();
  1022. }
  1023. ////////////////////////////////////////////////////////////////////
  1024. // Function: TransformState::calc_hpr
  1025. // Access: Private
  1026. // Description: Derives the hpr, from the matrix if necessary, or
  1027. // from the quat.
  1028. ////////////////////////////////////////////////////////////////////
  1029. INLINE void TransformState::
  1030. calc_hpr() {
  1031. LightMutexHolder holder(_lock);
  1032. do_calc_hpr();
  1033. }
  1034. ////////////////////////////////////////////////////////////////////
  1035. // Function: TransformState::calc_mat
  1036. // Access: Private
  1037. // Description: Computes the matrix from the components.
  1038. ////////////////////////////////////////////////////////////////////
  1039. INLINE void TransformState::
  1040. calc_mat() {
  1041. LightMutexHolder holder(_lock);
  1042. do_calc_mat();
  1043. }
  1044. ////////////////////////////////////////////////////////////////////
  1045. // Function: TransformState::check_uniform_scale
  1046. // Access: Private
  1047. // Description: Should be called immediately after _scale (and
  1048. // F_has_components) is set, this checks for a
  1049. // identity and/or uniform scale (as well as a non-zero
  1050. // shear) and sets the bit appropriately.
  1051. //
  1052. // It does not matter whether the lock is or is not held
  1053. // before calling this method.
  1054. ////////////////////////////////////////////////////////////////////
  1055. INLINE void TransformState::
  1056. check_uniform_scale() {
  1057. if (IS_NEARLY_EQUAL(_scale[0], _scale[1]) &&
  1058. IS_NEARLY_EQUAL(_scale[0], _scale[2])) {
  1059. _flags |= F_uniform_scale;
  1060. if (IS_NEARLY_EQUAL(_scale[0], 1.0f)) {
  1061. _flags |= F_identity_scale;
  1062. }
  1063. }
  1064. if (!_shear.almost_equal(LVecBase3f::zero())) {
  1065. _flags |= F_has_nonzero_shear;
  1066. }
  1067. }
  1068. ////////////////////////////////////////////////////////////////////
  1069. // Function: TransformState::check_uniform_scale2d
  1070. // Access: Private
  1071. // Description: Should be called immediately after _scale (and
  1072. // F_has_components) is set, for a known 2-d scale, this
  1073. // checks for a identity and/or uniform scale (as well
  1074. // as a non-zero shear) and sets the bit appropriately.
  1075. //
  1076. // It does not matter whether the lock is or is not held
  1077. // before calling this method.
  1078. ////////////////////////////////////////////////////////////////////
  1079. INLINE void TransformState::
  1080. check_uniform_scale2d() {
  1081. if (IS_NEARLY_EQUAL(_scale[0], _scale[1])) {
  1082. _scale[2] = _scale[0];
  1083. _flags |= F_uniform_scale;
  1084. if (IS_NEARLY_EQUAL(_scale[0], 1.0f)) {
  1085. _flags |= F_identity_scale;
  1086. }
  1087. }
  1088. if (!_shear.almost_equal(LVecBase3f::zero())) {
  1089. _flags |= F_has_nonzero_shear;
  1090. }
  1091. }
  1092. ////////////////////////////////////////////////////////////////////
  1093. // Function: TransformState::set_destructing
  1094. // Access: Private
  1095. // Description: This function should only be called from the
  1096. // destructor; it indicates that this TransformState
  1097. // object is beginning destruction. It is only used as
  1098. // a sanity check, and is only meaningful when NDEBUG is
  1099. // not defined.
  1100. ////////////////////////////////////////////////////////////////////
  1101. INLINE void TransformState::
  1102. set_destructing() {
  1103. #ifndef NDEBUG
  1104. _flags |= F_is_destructing;
  1105. #endif
  1106. }
  1107. ////////////////////////////////////////////////////////////////////
  1108. // Function: TransformState::is_destructing
  1109. // Access: Private
  1110. // Description: Returns true if the TransformState object is
  1111. // currently within its destructor
  1112. // (i.e. set_destructing() has been called). This is
  1113. // only used as a sanity check, and is only meaningful
  1114. // when NDEBUG is not defined.
  1115. ////////////////////////////////////////////////////////////////////
  1116. INLINE bool TransformState::
  1117. is_destructing() const {
  1118. #ifndef NDEBUG
  1119. return (_flags & F_is_destructing) != 0;
  1120. #else
  1121. return false;
  1122. #endif
  1123. }
  1124. ////////////////////////////////////////////////////////////////////
  1125. // Function: TransformState::consider_update_pstats
  1126. // Access: Private
  1127. // Description: Calls update_pstats() if the state of the referenced
  1128. // bits has changed from the indicated value.
  1129. ////////////////////////////////////////////////////////////////////
  1130. INLINE void TransformState::
  1131. consider_update_pstats(int old_referenced_bits) const {
  1132. #ifdef DO_PSTATS
  1133. int new_referenced_bits = get_referenced_bits();
  1134. if (old_referenced_bits != new_referenced_bits) {
  1135. update_pstats(old_referenced_bits, new_referenced_bits);
  1136. }
  1137. #endif // DO_PSTATS
  1138. }
  1139. ////////////////////////////////////////////////////////////////////
  1140. // Function: TransformState::Composition::Constructor
  1141. // Access: Public
  1142. // Description:
  1143. ////////////////////////////////////////////////////////////////////
  1144. INLINE TransformState::Composition::
  1145. Composition() {
  1146. }
  1147. ////////////////////////////////////////////////////////////////////
  1148. // Function: TransformState::Composition::Copy Constructor
  1149. // Access: Public
  1150. // Description:
  1151. ////////////////////////////////////////////////////////////////////
  1152. INLINE TransformState::Composition::
  1153. Composition(const TransformState::Composition &copy) :
  1154. _result(copy._result)
  1155. {
  1156. }
  1157. ////////////////////////////////////////////////////////////////////
  1158. // Function: TransformState::CompositionCycleDescEntry::Constructor
  1159. // Access: Public
  1160. // Description:
  1161. ////////////////////////////////////////////////////////////////////
  1162. INLINE TransformState::CompositionCycleDescEntry::
  1163. CompositionCycleDescEntry(const TransformState *obj,
  1164. const TransformState *result,
  1165. bool inverted) :
  1166. _obj(obj),
  1167. _result(result),
  1168. _inverted(inverted)
  1169. {
  1170. }