I did have the same problem with a WakeupOnElapsedTime behaviour I wrote.
Basically, I needed to disable the behaviour from time to time.
Originally, I just assumed that setEnable() would do the trick but I
observed that the behaviour code was chewing up my cpu cycles even when
the program was supposed to be idling. My quick and dirty solution was to
override setEnable method and handle it with a  WakeupOnBehaviorPost for
enabling and disabling the behaviour. here's my bit of code


    public void setEnable(boolean isEnable) {
        this.isEnable = isEnable;
        if (isEnable) {
            // start on the next time interval, w is my wakeupOn 
            // criteria at the end of the processStimulus method
            w = new WakeupOnElapsedTime(timeStep);
            // trigger manual wakeup condition. RUN is just a const id
            postId(this.RUN); 
        } else {
            // set wakeup condition to manual enable, where
            // wakeupOnEnable = new WakeupOnBehaviorPost(this, RUN);
            w = wakeupOnEnable;
        }
    }

My hunch is that, even though the behaviour code has been disabled, the
higher level scheduler is still scheduling it to run. After I nad fixed
this problem, the overall program performs much better.

Anybody else have this problem?? or is there a better way to disable a
behaviour.

rOnn c.

 On Mon, 7 Jun 1999, Vasilios
Darlagiannis wrote:

> Hi everyone,
>     I have tried all the examples about collision detection
> that have been send in the mailing list, but all of them have
> the same problem. They are making 100% utilization of the
> processor and in some more abvance cases this becomes
> a problem. Is it natural that the utilization is 100%?  Or
> those examples are missing something?
>     I tried to solve the problem by setEnable(b) where b is
> true when the mouseBehavior detects a motion and false
> otherwise, but it didn't work. Does anybody have another idea?
> 
>     Cheers,
> 
>     Vasilis
> 
> 
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 3D Home Page: http://java.sun.com/products/java-media/3D/
> 

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to