Cleaning thumbs on new scene, removelayer not removing all layers?

  • Hi,
    I call my action on startup, at the end of the starup actions chain.
    Here's the code:

    Code
    <action name="remove_thumbs">
    for(set(i,0), i LT layer.count, inc(i),	if(layer[get(i)].parent EQ 'skin_thumbs',		trace('Layer: ',get(layer[get(i)].name));		removelayer(get(layer[get(i)].name), true);	););</action>


    It lists the layers correctly, but only randomly removes about a third. It doesn't make sense.
    If I call the action 4-5 times in a row it will delete most of the thumbs.

    I'd appreciate some feedback.

  • I wouldn't propose to count all layers, check style. Additionally I think indexes are changed when you remove one element. Why not doing like this:

    Code
    <action name="remove_thumbs">		
    for(set(i,0), i LT scene.count, inc(i),
    	inc(thumb_cnt);
    	txtadd(thumbname,'skin_thumb_',get(i));
    	removelayer(get(thumbname),true);
    );
    </action>
  • I wouldn't say it is strange, more like normal behavior. It would be strange to have indexes where some elements are reserved by deleted array element. If you must use indexes maybe you can try deleting elements in reverse order so that last element you delete is index 0.

  • Additionally I think indexes are changed when you remove one element.


    Ah, that makes sense.

    I wouldn't propose to count all layers, check style. Why not doing like this:

    That can't be avoided as I'm interested in removing thumbs from scenes that are not loaded.

    I did find a way to go about it (a sane way :)), but I still want to understand Krpano better.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!