gd_cubism icon indicating copy to clipboard operation
gd_cubism copied to clipboard

_process, _ready etc. should be handled in _notification

Open mr11stein opened this issue 7 months ago • 0 comments

This is something I noticed when I tried to attach a script to a GDUserModel. When you override _process like so:

extends GDCubismUserModel
func _process(delta):
    #do some stuff

It breaks rendering, because the original C++ _process method isn't called anymore. You can also expose the methods for GDScript and make them callable via super() but that doesn't make much sense imo.

This is how I did it in my RenderingDevice branch:

void GDCubismUserModel::_notification(int p_what) {
    if (p_what == NOTIFICATION_PREDELETE) {
        this->clear();
    }
    if (p_what == NOTIFICATION_READY) {
        this->ready();
    }
    if (p_what == NOTIFICATION_PROCESS) {
        this->process(get_process_delta_time());
    }
    if (p_what == NOTIFICATION_PHYSICS_PROCESS) {
        this->physics_process(get_physics_process_delta_time());
    }
}

void GDCubismUserModel::ready() {
    if (!this->assets.is_empty()) {
        this->load_model(this->assets);
    }
    set_process(true);
    set_physics_process(true);
}

mr11stein avatar Jul 22 '25 08:07 mr11stein