@@ -160,6 +160,8 @@ RS::InstanceType Utilities::get_base_type(RID p_rid) const {
160160 return RS::INSTANCE_PARTICLES;
161161 } else if (GLES3::ParticlesStorage::get_singleton ()->owns_particles_collision (p_rid)) {
162162 return RS::INSTANCE_PARTICLES_COLLISION;
163+ } else if (owns_visibility_notifier (p_rid)) {
164+ return RS::INSTANCE_VISIBLITY_NOTIFIER;
163165 }
164166 return RS::INSTANCE_NONE;
165167}
@@ -207,6 +209,9 @@ bool Utilities::free(RID p_rid) {
207209 } else if (GLES3::MeshStorage::get_singleton ()->owns_skeleton (p_rid)) {
208210 GLES3::MeshStorage::get_singleton ()->skeleton_free (p_rid);
209211 return true ;
212+ } else if (owns_visibility_notifier (p_rid)) {
213+ visibility_notifier_free (p_rid);
214+ return true ;
210215 } else {
211216 return false ;
212217 }
@@ -233,32 +238,69 @@ void Utilities::base_update_dependency(RID p_base, DependencyTracker *p_instance
233238 } else if (ParticlesStorage::get_singleton ()->owns_particles_collision (p_base)) {
234239 Dependency *dependency = ParticlesStorage::get_singleton ()->particles_collision_get_dependency (p_base);
235240 p_instance->update_dependency (dependency);
241+ } else if (owns_visibility_notifier (p_base)) {
242+ VisibilityNotifier *vn = get_visibility_notifier (p_base);
243+ p_instance->update_dependency (&vn->dependency );
236244 }
237245}
238246
239247/* VISIBILITY NOTIFIER */
240248
241249RID Utilities::visibility_notifier_allocate () {
242- return RID ();
250+ return visibility_notifier_owner. allocate_rid ();
243251}
244252
245253void Utilities::visibility_notifier_initialize (RID p_notifier) {
254+ visibility_notifier_owner.initialize_rid (p_notifier, VisibilityNotifier ());
246255}
247256
248257void Utilities::visibility_notifier_free (RID p_notifier) {
258+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null (p_notifier);
259+ vn->dependency .deleted_notify (p_notifier);
260+ visibility_notifier_owner.free (p_notifier);
249261}
250262
251263void Utilities::visibility_notifier_set_aabb (RID p_notifier, const AABB &p_aabb) {
264+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null (p_notifier);
265+ ERR_FAIL_NULL (vn);
266+ vn->aabb = p_aabb;
267+ vn->dependency .changed_notify (Dependency::DEPENDENCY_CHANGED_AABB);
252268}
253269
254270void Utilities::visibility_notifier_set_callbacks (RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) {
271+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null (p_notifier);
272+ ERR_FAIL_NULL (vn);
273+ vn->enter_callback = p_enter_callbable;
274+ vn->exit_callback = p_exit_callable;
255275}
256276
257277AABB Utilities::visibility_notifier_get_aabb (RID p_notifier) const {
258- return AABB ();
278+ const VisibilityNotifier *vn = visibility_notifier_owner.get_or_null (p_notifier);
279+ ERR_FAIL_NULL_V (vn, AABB ());
280+ return vn->aabb ;
259281}
260282
261283void Utilities::visibility_notifier_call (RID p_notifier, bool p_enter, bool p_deferred) {
284+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null (p_notifier);
285+ ERR_FAIL_NULL (vn);
286+
287+ if (p_enter) {
288+ if (!vn->enter_callback .is_null ()) {
289+ if (p_deferred) {
290+ vn->enter_callback .call_deferred ();
291+ } else {
292+ vn->enter_callback .call ();
293+ }
294+ }
295+ } else {
296+ if (!vn->exit_callback .is_null ()) {
297+ if (p_deferred) {
298+ vn->exit_callback .call_deferred ();
299+ } else {
300+ vn->exit_callback .call ();
301+ }
302+ }
303+ }
262304}
263305
264306/* TIMING */
0 commit comments