@@ -317,10 +317,25 @@ def enable_health_visualization(self):
317317 return False
318318
319319 def disable_health_visualization (self ):
320+ # Clear object highlights
321+ if self ._health_tracked_object_names is not None :
322+ for obj_name in self ._health_tracked_object_names :
323+ try :
324+ obj = self .scene .object_registry ("name" , obj_name )
325+ if obj is not None :
326+ obj .highlighted = False
327+ except Exception :
328+ pass
320329 if self ._health_fig is not None :
321330 try :
322331 import matplotlib .pyplot as plt
323- plt .close (self ._health_fig )
332+ if plt .fignum_exists (self ._health_fig .number ):
333+ plt .close (self ._health_fig )
334+ except Exception :
335+ pass
336+ try :
337+ import matplotlib .pyplot as plt
338+ plt .ioff ()
324339 except Exception :
325340 pass
326341 self ._health_visualization_enabled = False
@@ -341,13 +356,25 @@ def update_health_visualization(self, obs=None):
341356 else :
342357 health_arr = np .asarray (health_arr )
343358 link_healths = {}
344- for idx , name in enumerate (self .health_list_part_names ):
359+ for idx , name in enumerate (self .health_list_link_names ):
345360 if idx < len (health_arr ):
346361 link_healths [name ] = health_arr [idx ]
347362 current = {}
348363 for obj_name in self ._health_tracked_object_names :
349364 vals = [v for k , v in link_healths .items () if k .startswith (f"{ obj_name } @" )]
350365 current [obj_name ] = min (vals ) if vals else 100.0
366+
367+ # Live object coloring: tint objects red proportionally to damage
368+ for obj_name in self ._health_tracked_object_names :
369+ try :
370+ obj = self .scene .object_registry ("name" , obj_name )
371+ if obj is not None :
372+ intensity = 10000 * (100.0 - current [obj_name ]) / 100.0
373+ obj .set_highlight_properties (color = [255.0 , 0.0 , 0.0 ], intensity = intensity )
374+ obj .highlighted = True
375+ except Exception :
376+ pass
377+
351378 try :
352379 return update_live_health_bars (
353380 self ._health_fig , self ._health_ax , self ._health_bars_dict ,
0 commit comments