MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / init

Method init

Source/Node/Particle.cpp:205–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203ParticleNode::~ParticleNode() { }
204
205bool ParticleNode::init() {
206 if (!Node::init()) return false;
207 if (!_particleDef) {
208 setAsManaged();
209 return false;
210 }
211 _particles.reserve(_particleDef->maxParticles);
212 _quads.reserve(_particleDef->maxParticles);
213 Rect textureRect = _particleDef->textureRect;
214 if (!_particleDef->textureName.empty()) {
215 if (SharedClipCache.isClip(_particleDef->textureName) && SharedClipCache.isFileExist(_particleDef->textureName)) {
216 Texture2D* tex = nullptr;
217 Rect rect;
218 std::tie(tex, rect) = SharedClipCache.loadTexture(_particleDef->textureName);
219 if (tex) {
220 _texture = tex;
221 textureRect = rect;
222 }
223 } else if (SharedContent.exist(_particleDef->textureName) && !SharedContent.isFolder(_particleDef->textureName)) {
224 _texture = SharedTextureCache.load(_particleDef->textureName);
225 }
226 }
227 if (!_texture) {
228 textureRect = Rect::zero;
229 _texture = SharedTextureCache.get("__defaultParticleTexture.png");
230 if (!_texture) {
231 _texture = SharedTextureCache.update(
232 "__defaultParticleTexture.png",
233 __defaultParticleTexturePng,
234 sizeof(__defaultParticleTexturePng));
235 }
236 }
237 if (textureRect != Rect::zero) {
238 const bgfx::TextureInfo& info = _texture->getInfo();
239 _texLeft = textureRect.getX() / info.width;
240 _texTop = textureRect.getY() / info.height;
241 _texRight = (textureRect.getX() + textureRect.getWidth()) / info.width;
242 _texBottom = (textureRect.getY() + textureRect.getHeight()) / info.height;
243 } else {
244 _texRight = 1.0f;
245 _texBottom = 1.0f;
246 }
247 return true;
248}
249
250bool ParticleNode::isActive() const noexcept {
251 return _flags.isOn(ParticleNode::Active);

Callers

nothing calls this directly

Calls 15

isClipMethod · 0.80
loadTextureMethod · 0.80
existMethod · 0.65
loadMethod · 0.65
getMethod · 0.65
initFunction · 0.50
reserveMethod · 0.45
emptyMethod · 0.45
isFileExistMethod · 0.45
isFolderMethod · 0.45
updateMethod · 0.45
getInfoMethod · 0.45

Tested by

no test coverage detected