BillboardSet.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #include "Precompiled.h"
  24. #include "BillboardSet.h"
  25. #include "Camera.h"
  26. #include "Geometry.h"
  27. #include "IndexBuffer.h"
  28. #include "Material.h"
  29. #include "Profiler.h"
  30. #include "Renderer.h"
  31. #include "RendererImpl.h"
  32. #include "ReplicationUtils.h"
  33. #include "ResourceCache.h"
  34. #include "VertexBuffer.h"
  35. #include "XMLElement.h"
  36. #include <algorithm>
  37. #include "DebugNew.h"
  38. std::vector<float> sortDistances;
  39. static bool compareBillboards(unsigned lhs, unsigned rhs)
  40. {
  41. return sortDistances[lhs] > sortDistances[rhs];
  42. }
  43. BillboardSet::BillboardSet(Octant* octant, const std::string& name) :
  44. GeometryNode(NODE_BILLBOARDSET, octant, name),
  45. mAnimationLodBias(1.0f),
  46. mAnimationLodTimer(0.0f),
  47. mBillboardsRelative(true),
  48. mBillboardsSorted(false),
  49. mScaleBillboards(true),
  50. mBufferSizeDirty(true),
  51. mBufferDirty(true),
  52. mForceUpdate(false),
  53. mPreviousOffset(Vector3::sZero),
  54. mSortFrameNumber(M_MAX_UNSIGNED)
  55. {
  56. mGeometry = new Geometry();
  57. }
  58. BillboardSet::~BillboardSet()
  59. {
  60. }
  61. void BillboardSet::save(Serializer& dest)
  62. {
  63. // Write GeometryNode properties
  64. GeometryNode::save(dest);
  65. // Write BillboardSet properties
  66. dest.writeStringHash(getResourceHash(mMaterial));
  67. dest.writeFloat(mAnimationLodBias);
  68. dest.writeBool(mBillboardsRelative);
  69. dest.writeBool(mBillboardsSorted);
  70. dest.writeBool(mScaleBillboards);
  71. dest.writeVLE(mBillboards.size());
  72. for (unsigned i = 0; i < mBillboards.size(); ++i)
  73. {
  74. const Billboard& billboard = mBillboards[i];
  75. dest.writeBool(billboard.mEnabled);
  76. // Optimization: write only enabled billboards
  77. if (billboard.mEnabled)
  78. {
  79. dest.writeVector3(billboard.mPosition);
  80. dest.writeVector2(billboard.mSize);
  81. dest.writeRect(billboard.mUV);
  82. dest.writeColor(billboard.mColor);
  83. dest.writeFloat(billboard.mRotation);
  84. }
  85. }
  86. }
  87. void BillboardSet::load(Deserializer& source, ResourceCache* cache)
  88. {
  89. // Read GeometryNode properties
  90. GeometryNode::load(source, cache);
  91. // Read BillboardSet properties
  92. mMaterial = cache->getResource<Material>(source.readStringHash());
  93. mAnimationLodBias = source.readFloat();
  94. mBillboardsRelative = source.readBool();
  95. mBillboardsSorted = source.readBool();
  96. mScaleBillboards = source.readBool();
  97. setNumBillboards(source.readVLE());
  98. for (unsigned i = 0; i < mBillboards.size(); ++i)
  99. {
  100. Billboard& billboard = mBillboards[i];
  101. billboard.mEnabled = source.readBool();
  102. if (billboard.mEnabled)
  103. {
  104. billboard.mPosition = source.readVector3();
  105. billboard.mSize = source.readVector2();
  106. billboard.mUV = source.readRect();
  107. billboard.mColor = source.readColor();
  108. billboard.mRotation = source.readFloat();
  109. }
  110. else
  111. {
  112. billboard.mPosition = Vector3::sZero;
  113. billboard.mSize = Vector2::sZero;
  114. billboard.mUV = Rect::sPositiveRect;
  115. billboard.mColor = Color();
  116. billboard.mRotation = 0.0f;
  117. }
  118. }
  119. markPositionsDirty();
  120. }
  121. void BillboardSet::saveXML(XMLElement& dest)
  122. {
  123. // Write GeometryNode properties
  124. GeometryNode::saveXML(dest);
  125. // Write BillboardSet properties
  126. XMLElement billboardsElem = dest.createChildElement("billboards");
  127. billboardsElem.setString("materialname", getResourceName(mMaterial));
  128. billboardsElem.setBool("relative", mBillboardsRelative);
  129. billboardsElem.setBool("sort", mBillboardsSorted);
  130. billboardsElem.setBool("scale", mScaleBillboards);
  131. billboardsElem.setInt("count", mBillboards.size());
  132. XMLElement lodElem = dest.getChildElement("lod");
  133. lodElem.setFloat("animlodbias", mAnimationLodBias);
  134. for (unsigned i = 0; i < mBillboards.size(); ++i)
  135. {
  136. XMLElement billboardElem = dest.createChildElement("billboard");
  137. const Billboard& billboard = mBillboards[i];
  138. // Optimization: write only enabled billboards
  139. if (billboard.mEnabled)
  140. {
  141. billboardElem.setVector3("pos", billboard.mPosition);
  142. billboardElem.setVector2("size", billboard.mSize);
  143. billboardElem.setRect("uv", billboard.mUV);
  144. billboardElem.setColor("color", billboard.mColor);
  145. billboardElem.setFloat("rot", billboard.mRotation);
  146. }
  147. }
  148. }
  149. void BillboardSet::loadXML(const XMLElement& source, ResourceCache* cache)
  150. {
  151. // Read GeometryNode properties
  152. GeometryNode::loadXML(source, cache);
  153. // Read BillboardSet properties
  154. XMLElement billboardsElem = source.getChildElement("billboards");
  155. mMaterial = cache->getResource<Material>(billboardsElem.getString("materialname"));
  156. mBillboardsRelative = billboardsElem.getBool("relative");
  157. mBillboardsSorted = billboardsElem.getBool("sort");
  158. mScaleBillboards = billboardsElem.getBool("scale");
  159. setNumBillboards(billboardsElem.getInt("count"));
  160. XMLElement lodElem = source.getChildElement("lod");
  161. mAnimationLodBias = lodElem.getFloat("animlodbias");
  162. XMLElement billboardElem = source.getChildElement("billboard");
  163. unsigned index = 0;
  164. while ((billboardElem) && (index < mBillboards.size()))
  165. {
  166. Billboard& billboard = mBillboards[index];
  167. billboard.mEnabled = billboardElem.hasAttribute("pos");
  168. if (billboard.mEnabled)
  169. {
  170. billboard.mPosition = billboardElem.getVector3("pos");
  171. billboard.mSize = billboardElem.getVector2("size");
  172. billboard.mUV = billboardElem.getRect("uv");
  173. billboard.mColor = billboardElem.getColor("color");
  174. billboard.mRotation = billboardElem.getFloat("rot");
  175. }
  176. billboardElem = billboardElem.getNextElement("billboard");
  177. ++index;
  178. }
  179. markPositionsDirty();
  180. }
  181. bool BillboardSet::writeNetUpdate(Serializer& dest, Serializer& destRevision, Deserializer& baseRevision, const NetUpdateInfo& info)
  182. {
  183. // Write GeometryNode properties and see if there were any changes
  184. bool prevBits = GeometryNode::writeNetUpdate(dest, destRevision, baseRevision, info);
  185. // Build bitmask of changed properties
  186. unsigned char bits = 0;
  187. // Note: material is not serialized here. The assumption is that network serialized billboard sets are
  188. // ParticleEmitters, which have their own description resource
  189. checkFloat(mAnimationLodBias, baseRevision, bits, 1);
  190. checkBool(mBillboardsRelative, baseRevision, bits, 2);
  191. checkBool(mBillboardsSorted, baseRevision, bits, 4);
  192. checkBool(mScaleBillboards, baseRevision, bits, 8);
  193. // Update replication state fully, and network stream by delta
  194. dest.writeUByte(bits);
  195. writeFloatDelta(mAnimationLodBias, dest, destRevision, bits & 1);
  196. writeBoolDelta(mBillboardsRelative, dest, destRevision, bits & 2);
  197. writeBoolDelta(mBillboardsSorted, dest, destRevision, bits & 4);
  198. writeBoolDelta(mScaleBillboards, dest, destRevision, bits & 8);
  199. return prevBits || (bits != 0);
  200. }
  201. void BillboardSet::readNetUpdate(Deserializer& source, ResourceCache* cache, const NetUpdateInfo& info)
  202. {
  203. // Read GeometryNode properties
  204. GeometryNode::readNetUpdate(source, cache, info);
  205. unsigned char bits = source.readUByte();
  206. readFloatDelta(mAnimationLodBias, source, bits & 1);
  207. readBoolDelta(mBillboardsRelative, source, bits & 2);
  208. readBoolDelta(mBillboardsSorted, source, bits & 4);
  209. readBoolDelta(mScaleBillboards, source, bits & 8);
  210. if (bits)
  211. markPositionsDirty();
  212. }
  213. void BillboardSet::getResourceRefs(std::vector<Resource*>& dest)
  214. {
  215. if (mMaterial)
  216. dest.push_back(mMaterial);
  217. }
  218. void BillboardSet::updateDistance(const FrameInfo& frame)
  219. {
  220. // Check if position relative to camera has changed, and re-sort in that case
  221. const Vector3& worldPos = getWorldPosition();
  222. Vector3 offset = (worldPos - frame.mCamera->getWorldPosition());
  223. if (offset != mPreviousOffset)
  224. {
  225. mPreviousOffset = offset;
  226. if (mBillboardsSorted)
  227. {
  228. // Sort billboards only once per frame. This means that secondary views will get
  229. // the same sorting as the main view
  230. if (frame.mFrameNumber != mSortFrameNumber)
  231. {
  232. mSortFrameNumber = frame.mFrameNumber;
  233. mBufferDirty = true;
  234. }
  235. }
  236. }
  237. mDistance = frame.mCamera->getDistance(worldPos);
  238. // Calculate scaled distance for animation LOD
  239. static const Vector3 dotScale(1 / 3.0f, 1 / 3.0f, 1 / 3.0f);
  240. float scale = getWorldBoundingBox().getSize().dotProduct(dotScale);
  241. // If there are no billboards, the size becomes zero, and LOD'ed updates no longer happen. Disable LOD in that case
  242. if (scale > M_EPSILON)
  243. mLodDistance = frame.mCamera->getLodDistance(mDistance, scale, mLodBias);
  244. else
  245. mLodDistance = 0.0f;
  246. }
  247. void BillboardSet::updateGeometry(const FrameInfo& frame, Renderer* renderer)
  248. {
  249. if (mBufferSizeDirty)
  250. {
  251. updateBufferSize(renderer);
  252. mForceUpdate = true;
  253. }
  254. if (mVertexBuffer->isDataLost())
  255. {
  256. mVertexBuffer->clearDataLost();
  257. mForceUpdate = true;
  258. }
  259. if ((mBufferDirty) || (mForceUpdate))
  260. updateVertexBuffer(frame);
  261. }
  262. unsigned BillboardSet::getNumBatches()
  263. {
  264. return 1;
  265. }
  266. Geometry* BillboardSet::getBatchGeometry(unsigned batchIndex)
  267. {
  268. return mGeometry;
  269. }
  270. Material* BillboardSet::getBatchMaterial(unsigned batchIndex)
  271. {
  272. return mMaterial;
  273. }
  274. void BillboardSet::setMaterial(Material* material)
  275. {
  276. mMaterial = material;
  277. }
  278. void BillboardSet::setNumBillboards(unsigned num)
  279. {
  280. unsigned oldNum = mBillboards.size();
  281. mBillboards.resize(num);
  282. mSortOrder.resize(num);
  283. // Set default values to new billboards
  284. for (unsigned i = oldNum; i < num; ++i)
  285. {
  286. mBillboards[i].mPosition = Vector3::sZero;
  287. mBillboards[i].mSize = Vector2::sUnity;
  288. mBillboards[i].mUV = Rect::sPositiveRect;
  289. mBillboards[i].mColor = Color(1.0f, 1.0f, 1.0f);
  290. mBillboards[i].mRotation = 0.0f;
  291. mBillboards[i].mEnabled = false;
  292. }
  293. // Set default sort order
  294. for (unsigned i = 0; i < num; ++i)
  295. mSortOrder[i] = i;
  296. mBufferSizeDirty = true;
  297. markPositionsDirty();
  298. }
  299. void BillboardSet::setBillboardsRelative(bool enable)
  300. {
  301. mBillboardsRelative = enable;
  302. markPositionsDirty();
  303. }
  304. void BillboardSet::setBillboardsSorted(bool enable)
  305. {
  306. mBillboardsSorted = enable;
  307. if (!enable)
  308. {
  309. // Set default sort order
  310. for (unsigned i = 0; i < mBillboards.size(); ++i)
  311. mSortOrder[i] = i;
  312. }
  313. markPositionsDirty();
  314. }
  315. void BillboardSet::setScaleBillboards(bool enable)
  316. {
  317. mScaleBillboards = enable;
  318. markPositionsDirty();
  319. }
  320. void BillboardSet::setAnimationLodBias(float bias)
  321. {
  322. mAnimationLodBias = max(bias, 0.0f);
  323. }
  324. void BillboardSet::updated()
  325. {
  326. markPositionsDirty();
  327. }
  328. Billboard* BillboardSet::getBillboard(unsigned index)
  329. {
  330. if (index >= mBillboards.size())
  331. return 0;
  332. return &mBillboards[index];
  333. }
  334. void BillboardSet::onMarkedDirty()
  335. {
  336. VolumeNode::onMarkedDirty();
  337. if (mBillboardsRelative)
  338. mBufferDirty = true;
  339. }
  340. void BillboardSet::onWorldBoundingBoxUpdate(BoundingBox& worldBoundingBox)
  341. {
  342. worldBoundingBox.mDefined = false;
  343. unsigned enabledBillboards = 0;
  344. const Matrix4x3& worldTransform = getWorldTransform();
  345. const Vector3& worldScale = getWorldScale();
  346. for (unsigned i = 0; i < mBillboards.size(); ++i)
  347. {
  348. if (!mBillboards[i].mEnabled)
  349. continue;
  350. float maxSize;
  351. if (!mScaleBillboards)
  352. maxSize = max(mBillboards[i].mSize.mX, mBillboards[i].mSize.mY);
  353. else
  354. maxSize = max(mBillboards[i].mSize.mX * worldScale.mX, mBillboards[i].mSize.mY * worldScale.mY);
  355. if (!mBillboardsRelative)
  356. worldBoundingBox.merge(Sphere(mBillboards[i].mPosition, maxSize));
  357. else
  358. worldBoundingBox.merge(Sphere(worldTransform * mBillboards[i].mPosition, maxSize));
  359. ++enabledBillboards;
  360. }
  361. // If no billboards enabled, the bounding box is just the node's world position
  362. if (!enabledBillboards)
  363. worldBoundingBox.merge(getWorldPosition());
  364. }
  365. void BillboardSet::updateBufferSize(Renderer* renderer)
  366. {
  367. PROFILE(BillboardSet_ResizeBuffer);
  368. if ((!mVertexBuffer) || (!mIndexBuffer))
  369. {
  370. mVertexBuffer = new VertexBuffer(renderer, true);
  371. mIndexBuffer = new IndexBuffer(renderer);
  372. mGeometry->setVertexBuffer(0, mVertexBuffer, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1 | MASK_TEXCOORD2);
  373. mGeometry->setIndexBuffer(mIndexBuffer);
  374. }
  375. unsigned numBillboards = mBillboards.size();
  376. mVertexBuffer->setSize(numBillboards * 4, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1 | MASK_TEXCOORD2);
  377. mIndexBuffer->setSize(numBillboards * 6, false);
  378. mBufferSizeDirty = false;
  379. mBufferDirty = true;
  380. if (!numBillboards)
  381. return;
  382. // Indices do not change for a given billboard capacity
  383. unsigned short* dest = (unsigned short*)mIndexBuffer->lock(0, numBillboards * 6, LOCK_DISCARD);
  384. unsigned vertexIndex = 0;
  385. while (numBillboards--)
  386. {
  387. *dest++ = vertexIndex; *dest++ = vertexIndex + 1; *dest++ = vertexIndex + 2;
  388. *dest++ = vertexIndex + 2; *dest++ = vertexIndex + 3; *dest++ = vertexIndex;
  389. vertexIndex += 4;
  390. }
  391. mIndexBuffer->unlock();
  392. }
  393. void BillboardSet::updateVertexBuffer(const FrameInfo& frame)
  394. {
  395. // If using animation LOD, accumulate time and see if it is time to update
  396. if ((mAnimationLodBias > 0.0f) && (mLodDistance > 0.0f))
  397. {
  398. mAnimationLodTimer += mAnimationLodBias * frame.mTimeStep * ANIMATION_LOD_BASESCALE;
  399. if (mAnimationLodTimer >= mLodDistance)
  400. mAnimationLodTimer = fmodf(mAnimationLodTimer, mLodDistance);
  401. else
  402. {
  403. // No LOD if immediate update forced
  404. if (!mForceUpdate)
  405. return;
  406. }
  407. }
  408. PROFILE(BillboardSet_UpdateBuffer);
  409. unsigned numBillboards = mBillboards.size();
  410. unsigned enabledBillboards = 0;
  411. const Matrix4x3& worldTransform = getWorldTransform();
  412. if (mBillboardsSorted)
  413. {
  414. sortDistances.resize(numBillboards);
  415. for (unsigned i = 0; i < numBillboards; ++i)
  416. {
  417. if (mBillboards[i].mEnabled)
  418. {
  419. if (!mBillboardsRelative)
  420. sortDistances[i] = frame.mCamera->getDistanceSquared(mBillboards[i].mPosition);
  421. else
  422. sortDistances[i] = frame.mCamera->getDistanceSquared(worldTransform * mBillboards[i].mPosition);
  423. enabledBillboards++;
  424. }
  425. else
  426. sortDistances[i] = 0.0f;
  427. }
  428. std::sort(mSortOrder.begin(), mSortOrder.end(), compareBillboards);
  429. }
  430. else
  431. {
  432. // If no sorting, do a prepass to find out number of enabled billboards
  433. for (unsigned i = 0; i < numBillboards; ++i)
  434. {
  435. if (mBillboards[i].mEnabled)
  436. ++enabledBillboards;
  437. }
  438. }
  439. // Draw range is now known
  440. mGeometry->setDrawRange(TRIANGLE_LIST, 0, enabledBillboards * 6, false);
  441. mBufferDirty = false;
  442. mForceUpdate = false;
  443. if (!enabledBillboards)
  444. return;
  445. float* dest = (float*)mVertexBuffer->lock(0, enabledBillboards * 4, LOCK_DISCARD);
  446. const Vector3& worldScale = getWorldScale();
  447. for (unsigned i = 0; i < numBillboards; ++i)
  448. {
  449. unsigned index = mSortOrder[i];
  450. const Billboard& billboard = mBillboards[index];
  451. if (!billboard.mEnabled)
  452. continue;
  453. Vector3 position;
  454. if (!mBillboardsRelative)
  455. position = billboard.mPosition;
  456. else
  457. position = worldTransform * billboard.mPosition;
  458. Vector2 size;
  459. if (!mScaleBillboards)
  460. size = billboard.mSize;
  461. else
  462. size = Vector2(billboard.mSize.mX * worldScale.mX, mBillboards[index].mSize.mY * worldScale.mY);
  463. unsigned color = getD3DColor(billboard.mColor);
  464. static float rotationMatrix[2][2];
  465. float angleRad = billboard.mRotation * M_DEGTORAD;
  466. rotationMatrix[0][0] = cosf(angleRad);
  467. rotationMatrix[0][1] = sinf(angleRad);
  468. rotationMatrix[1][0] = -rotationMatrix[0][1];
  469. rotationMatrix[1][1] = rotationMatrix[0][0];
  470. *dest++ = position.mX; *dest++ = position.mY; *dest++ = position.mZ;
  471. *((unsigned*)dest) = color; dest++;
  472. *dest++ = billboard.mUV.mMin.mX; *dest++ = billboard.mUV.mMax.mY;
  473. *dest++ = -size.mX * rotationMatrix[0][0] + size.mY * rotationMatrix[0][1];
  474. *dest++ = -size.mX * rotationMatrix[1][0] + size.mY * rotationMatrix[1][1];
  475. *dest++ = position.mX; *dest++ = position.mY; *dest++ = position.mZ;
  476. *((unsigned*)dest) = color; dest++;
  477. *dest++ = billboard.mUV.mMax.mX; *dest++ = billboard.mUV.mMax.mY;
  478. *dest++ = size.mX * rotationMatrix[0][0] + size.mY * rotationMatrix[0][1];
  479. *dest++ = size.mX * rotationMatrix[1][0] + size.mY * rotationMatrix[1][1];
  480. *dest++ = position.mX; *dest++ = position.mY; *dest++ = position.mZ;
  481. *((unsigned*)dest) = color; dest++;
  482. *dest++ = billboard.mUV.mMax.mX; *dest++ = billboard.mUV.mMin.mY;
  483. *dest++ = size.mX * rotationMatrix[0][0] - size.mY * rotationMatrix[0][1];
  484. *dest++ = size.mX * rotationMatrix[1][0] - size.mY * rotationMatrix[1][1];
  485. *dest++ = position.mX; *dest++ = position.mY; *dest++ = position.mZ;
  486. *((unsigned*)dest) = color; dest++;
  487. *dest++ = billboard.mUV.mMin.mX; *dest++ = billboard.mUV.mMin.mY;
  488. *dest++ = -size.mX * rotationMatrix[0][0] - size.mY * rotationMatrix[0][1];
  489. *dest++ = -size.mX * rotationMatrix[1][0] - size.mY * rotationMatrix[1][1];
  490. }
  491. mVertexBuffer->unlock();
  492. }
  493. void BillboardSet::markPositionsDirty()
  494. {
  495. VolumeNode::onMarkedDirty();
  496. mBufferDirty = true;
  497. }