Page 1 of 1

Trouble with RemoveAllModels of certain type

Posted: Sat Nov 29, 2014 1:02 pm
by Imerion
I have a RemoveAllModels component set to OfType to one of my models. But it seems to also remove a few more active models which I have not selected. Do I have to use it in a certain way? I don't think any of the models is set to parent or such.

The way I have set up those models makes it a bit complicated to remove them in another way, so using this would be very practical.

Re: Trouble with RemoveAllModels of certain type

Posted: Sat Nov 29, 2014 1:36 pm
by Kjell
Hi Imerion,
Imerion wrote:I have a RemoveAllModels component set to OfType to one of my models. But it seems to also remove a few more active models which I have not selected.
I suspect the models that are wrongly removed use the same BaseModel as the type you're using in RemoveAllModels? Since there's a bug causing that .. hopefully it will be fixed soon.

@Ville - Here's a example that illustrates the bug ..

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application">
  <OnLoaded>
    <SpawnModel Model="Apple" Position="-2 0 0"/>
    <SpawnModel Model="Orange" Position="2 0 0"/>
  </OnLoaded>
  <OnUpdate>
    <KeyPress Comment="Press A to remove Apples" Keys="A" RepeatDelay="0.25">
      <OnPressed>
        <RemoveAllModels OfType="Apple"/>
      </OnPressed>
    </KeyPress>
    <KeyPress Comment="Press O to remove Oranges" Keys="O" RepeatDelay="0.25">
      <OnPressed>
        <RemoveAllModels OfType="Orange"/>
      </OnPressed>
    </KeyPress>
  </OnUpdate>
  <Content>
    <Model Name="Fruit">
      <OnUpdate>
        <ZExpression Expression="Fruit.Rotation.Z = sin(App.Time + Fruit.Personality);"/>
      </OnUpdate>
    </Model>
    <Model Name="Apple" BaseModel="Fruit">
      <OnRender>
        <RenderSetColor Color="0.5922 0.8667 0.3412 1"/>
        <RenderSprite/>
      </OnRender>
    </Model>
    <Model Name="Orange" BaseModel="Fruit">
      <OnRender>
        <RenderSetColor Color="0.9608 0.6039 0.2471 1"/>
        <RenderSprite/>
      </OnRender>
    </Model>
  </Content>
</ZApplication>
K

Posted: Sat Nov 29, 2014 7:30 pm
by Rado1
The current behavior is not a bug, it's an intention. All instantiated models of the same category are removed at once. Kjell, in your example it is sufficient just to set different Category numbers for Apple and Orange.

I'm using this feature in my applications when needed to remove several different models of the same category at once but specify just one RemoveAllModels.

Posted: Sat Nov 29, 2014 8:26 pm
by Kjell
Hi Rado1,
Rado1 wrote:The current behavior is not a bug, it's an intention. All instantiated models of the same category are removed at once. Kjell, in your example it is sufficient just to set different Category numbers for Apple and Orange.
If it's not a bug it's at least confusing. In case it is the intended behavior it should have been called Category and take a enum / int instead of OfType and using a model as reference ( in my opinion ).

Even though i agree that removing all models of a certain category number can be convenient as well.

K

Posted: Sun Nov 30, 2014 12:12 am
by Imerion
Yep, that was it. Setting them to different category numbers worked!

Thanks for clearing this up! :)