Trouble with RemoveAllModels of certain type

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
Imerion
Posts: 200
Joined: Sun Feb 09, 2014 4:42 pm

Trouble with RemoveAllModels of certain type

Post 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.
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Re: Trouble with RemoveAllModels of certain type

Post 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
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post 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.
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Imerion
Posts: 200
Joined: Sun Feb 09, 2014 4:42 pm

Post by Imerion »

Yep, that was it. Setting them to different category numbers worked!

Thanks for clearing this up! :)
Post Reply