예제 #1
0
float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) {
	ERR_FAIL_INDEX_V(p_input, inputs.size(), 0);
	ERR_FAIL_COND_V(!state, 0);

	AnimationNodeBlendTree *blend_tree = Object::cast_to<AnimationNodeBlendTree>(parent);
	ERR_FAIL_COND_V(!blend_tree, 0);

	StringName node_name = connections[p_input];

	if (!blend_tree->has_node(node_name)) {
		String name = blend_tree->get_node_name(Ref<AnimationNode>(this));
		make_invalid(vformat(RTR("Nothing connected to input '%s' of node '%s'."), get_input_name(p_input), name));
		return 0;
	}

	Ref<AnimationNode> node = blend_tree->get_node(node_name);

	//inputs.write[p_input].last_pass = state->last_pass;
	float activity = 0;
	float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), NULL, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity);

	Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path);

	if (activity_ptr && p_input < activity_ptr->size()) {
		activity_ptr->write[p_input].last_pass = state->last_pass;
		activity_ptr->write[p_input].activity = activity;
	}
	return ret;
}
예제 #2
0
파일: miShell.c 프로젝트: owalch/oliver
int main(void) {
    char argstr[MAX_argv][STR_LEN];     // storage for command line arguments
    char *argv[MAX_argv];               // ptr array to command line arguments
    char *token;                        // ptr to command line token
    char buffer[STR_LEN];               // character buffer for command line
    char delimiter[] = " |\n\t";        // delimiter for the commands
    int idx;                            // index variable
    pid_t PID;                          // process identifier
    int fdw;                            // write file descriptor
    int fdr;                            // read file descriptor
    int ret;                            // ret value
    char pwd_buffer[PWD_LEN];           // buffer for the current directory
    char *fname_in_ptr = NULL;          // ptr to the input file name
    char *fname_out_ptr = NULL;         // ptr to the output file name
    
    /* reset screen */
    fprintf(stdout, "\E[0;0H");         // set cursor to 0;0
    fprintf(stdout, "\E[2J");           // clear screen
    
    /* get current directory as default */
    getcwd(pwd_buffer, PWD_LEN);
    
    while (1) {
        printf("# ");                   // set prompt
        readline(buffer, STR_LEN);      // read one line from stdin
        idx = 0;                        // set index back

        /* get token */
        token = strtok(buffer, delimiter);
        while (token != NULL) {
            strcpy(&(argstr[idx][0]), token);
            argv[idx] = argstr[idx];
            idx++;
            token = strtok(NULL, delimiter);
        }
        argv[idx] = NULL;               // terminate arguments with NULL pointer

        /* get input name if set */
        fname_in_ptr = get_input_name(argv, idx);
        
        /* get output name if is set */
        fname_out_ptr = get_output_name(argv, idx);

        /* check if logout or exit */
        exit_logout(argv);
        
        /* check if cd */
        ret = cd_cmd(argv, pwd_buffer);

        /* execute command */
        if (ret) {
            if ((PID = fork()) == 0) {      // fork child process
                /* check if write ptr is set */
                if (fname_out_ptr != NULL) {
                    close(1);               // close stdout, redirect to file
                    fdw = open(fname_out_ptr, O_CREAT | O_TRUNC | O_WRONLY, 0644);
                    if (fdw < 0 ){
                        fprintf(stderr, "Could not write to file %s\n", fname_out_ptr);
                        exit(-1);
                    }
                }

                if (fname_in_ptr != NULL) {
                    close(0);
                    fdr = open(fname_in_ptr, O_RDONLY);
                    if (fdr < 0 ){
                        fprintf(stderr, "Could not read file %s\n", fname_in_ptr);
                        exit(-1);
                    }
                }

                strcpy(buffer, "/bin/");    // "compose" path of command (1st arg)
                strcat(buffer, argv[0]);
                execv(buffer, &argv[0]);
                strcpy(buffer, "/usr/bin/");
                strcat(buffer, argv[0]);
                execv(buffer, &argv[0]);
                printf("%s: command not found\n", argv[0]);
                exit(0);                    // kill process
            }
            else if (PID < 0) {
                printf("fork failed\n");    // fork didn't succeed
                exit(-1);                   // terminate sishell
            }
            else                            // here we are parents
                wait(0);                    // wait for child process to terminate
        }
    }
}