这篇教程C++ ERR_FAIL_COND_V函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ERR_FAIL_COND_V函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_FAIL_COND_V函数的具体用法?C++ ERR_FAIL_COND_V怎么用?C++ ERR_FAIL_COND_V使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ERR_FAIL_COND_V函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ERR_EXPLAINError ResourceInteractiveLoaderBinary::poll(){ if (error!=OK) return error; int s = stage; if (s<external_resources.size()) { RES res = ResourceLoader::load(external_resources[s].path,external_resources[s].type); if (res.is_null()) { if (!ResourceLoader::get_abort_on_missing_resources()) { ResourceLoader::notify_load_error("Resource Not Found: "+external_resources[s].path); } else { error=ERR_FILE_CORRUPT; ERR_EXPLAIN("Can't load dependency: "+external_resources[s].path); ERR_FAIL_V(error); } } else { resource_cache.push_back(res); } stage++; return OK; } s-=external_resources.size(); if (s>=internal_resources.size()) { error=ERR_BUG; ERR_FAIL_COND_V(s>=internal_resources.size(),error); } bool main = s==(internal_resources.size()-1); //maybe it is loaded already String path; if (!main) { path=internal_resources[s].path; if (path.begins_with("local://")) path=path.replace("local://",res_path+"::"); if (ResourceCache::has(path)) { //already loaded, don't do anything stage++; error=OK; return error; } } else { path=res_path; } uint64_t offset = internal_resources[s].offset; f->seek(offset); String t = get_unicode_string(); Object *obj = ObjectTypeDB::instance(t); if (!obj) { error=ERR_FILE_CORRUPT; ERR_EXPLAIN(local_path+":Resource of unrecognized type in file: "+t); } ERR_FAIL_COND_V(!obj,ERR_FILE_CORRUPT); Resource *r = obj->cast_to<Resource>(); if (!r) { error=ERR_FILE_CORRUPT; memdelete(obj); //bye ERR_EXPLAIN(local_path+":Resoucre type in resource field not a resource, type is: "+obj->get_type()); ERR_FAIL_COND_V(!r,ERR_FILE_CORRUPT); } RES res = RES( r ); r->set_path(path); int pc = f->get_32(); //set properties for(int i=0;i<pc;i++) { uint32_t name_idx = f->get_32(); if (name_idx>=(uint32_t)string_map.size()) {//.........这里部分代码省略.........
开发者ID:0871087123,项目名称:godot,代码行数:101,
示例2: mt_lockError PoolAllocator::resize(ID p_mem,int p_new_size) { mt_lock(); Entry *e=get_entry(p_mem); if (!e) { mt_unlock(); ERR_FAIL_COND_V(!e,ERR_INVALID_PARAMETER); } if (needs_locking && e->lock) { mt_unlock(); ERR_FAIL_COND_V(e->lock,ERR_ALREADY_IN_USE); } int alloc_size = aligned(p_new_size); if (aligned(e->len)==alloc_size) { e->len=p_new_size; mt_unlock(); return OK; } else if (e->len>(uint32_t)p_new_size) { free_mem += aligned(e->len); free_mem -= alloc_size; e->len=p_new_size; mt_unlock(); return OK; } //p_new_size = align(p_new_size) int _total = pool_size; // - static_area_size; int _free = free_mem; // - static_area_size; if ((_free + aligned(e->len)) - alloc_size < 0) { mt_unlock(); ERR_FAIL_V( ERR_OUT_OF_MEMORY ); }; EntryIndicesPos entry_indices_pos; bool index_found = find_entry_index(&entry_indices_pos,e); if (!index_found) { mt_unlock(); ERR_FAIL_COND_V(!index_found,ERR_BUG); } //no need to move stuff around, it fits before the next block int next_pos; if (entry_indices_pos+1 == entry_count) { next_pos = pool_size; // - static_area_size; } else { next_pos = entry_array[entry_indices[entry_indices_pos+1]].pos; }; if ((next_pos - e->pos) > alloc_size) { free_mem+=aligned(e->len); e->len=p_new_size; free_mem-=alloc_size; mt_unlock(); return OK; } //it doesn't fit, compact around BEFORE current index (make room behind) compact(entry_indices_pos+1); if ((next_pos - e->pos) > alloc_size) { //now fits! hooray! free_mem+=aligned(e->len); e->len=p_new_size; free_mem-=alloc_size; mt_unlock(); if (free_mem<free_mem_peak) free_mem_peak=free_mem; return OK; } //STILL doesn't fit, compact around AFTER current index (make room after) compact_up(entry_indices_pos+1); if ((entry_array[entry_indices[entry_indices_pos+1]].pos - e->pos) > alloc_size) { //now fits! hooray! free_mem+=aligned(e->len); e->len=p_new_size; free_mem-=alloc_size; mt_unlock(); if (free_mem<free_mem_peak) free_mem_peak=free_mem; return OK; } mt_unlock(); ERR_FAIL_V(ERR_OUT_OF_MEMORY);}
开发者ID:111X,项目名称:godot,代码行数:100,
示例3: ERR_FAIL_COND_Vbool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2& p_from, const Vector2& p_to,RayResult &r_result,const Set<RID>& p_exclude,uint32_t p_user_mask) { ERR_FAIL_COND_V(space->locked,false); Vector2 begin,end; Vector2 normal; begin=p_from; end=p_to; normal=(end-begin).normalized(); int amount = space->broadphase->cull_segment(begin,end,space->intersection_query_results,Space2DSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results); //todo, create another array tha references results, compute AABBs and check closest point to ray origin, sort, and stop evaluating results when beyond first collision bool collided=false; Vector2 res_point,res_normal; int res_shape; const CollisionObject2DSW *res_obj; real_t min_d=1e10; for(int i=0;i<amount;i++) { if (space->intersection_query_results[i]->get_type()==CollisionObject2DSW::TYPE_AREA) continue; //ignore area if (p_exclude.has( space->intersection_query_results[i]->get_self())) continue; const CollisionObject2DSW *col_obj=space->intersection_query_results[i]; int shape_idx=space->intersection_query_subindex_results[i]; Matrix32 inv_xform = col_obj->get_shape_inv_transform(shape_idx) * col_obj->get_inv_transform(); Vector2 local_from = inv_xform.xform(begin); Vector2 local_to = inv_xform.xform(end); /*local_from = col_obj->get_inv_transform().xform(begin); local_from = col_obj->get_shape_inv_transform(shape_idx).xform(local_from); local_to = col_obj->get_inv_transform().xform(end); local_to = col_obj->get_shape_inv_transform(shape_idx).xform(local_to);*/ const Shape2DSW *shape = col_obj->get_shape(shape_idx); Vector2 shape_point,shape_normal; if (shape->intersect_segment(local_from,local_to,shape_point,shape_normal)) { //print_line("inters sgment!"); Matrix32 xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); shape_point=xform.xform(shape_point); real_t ld = normal.dot(shape_point); if (ld<min_d) { min_d=ld; res_point=shape_point; res_normal=inv_xform.basis_xform_inv(shape_normal).normalized(); res_shape=shape_idx; res_obj=col_obj; collided=true; } } } if (!collided) return false; r_result.collider_id=res_obj->get_instance_id(); if (r_result.collider_id!=0) r_result.collider=ObjectDB::get_instance(r_result.collider_id); r_result.normal=res_normal; r_result.position=res_point; r_result.rid=res_obj->get_self(); r_result.shape=res_shape; return true;}
开发者ID:Nr7,项目名称:godot,代码行数:87,
示例4: ERR_FAIL_COND_VError EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &texture,int format, float quality,int flags,EditorExportPlatform::ImageCompression p_compr,int tex_flags,float shrink) { if (format==IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS || format==IMAGE_FORMAT_COMPRESS_DISK_LOSSY) { Image image=texture->get_data(); ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); bool has_alpha=image.detect_alpha(); if (!has_alpha && image.get_format()==Image::FORMAT_RGBA) { image.convert(Image::FORMAT_RGB); } if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { image.fix_alpha_edges(); } if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_PREMULT_ALPHA) { image.premultiply_alpha(); } if (flags&IMAGE_FLAG_CONVERT_NORMAL_TO_XY) { image.normalmap_to_xy(); } //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { // image.srgb_to_linear(); //} if (shrink>1) { int orig_w=image.get_width(); int orig_h=image.get_height(); image.resize(orig_w/shrink,orig_h/shrink,Image::INTERPOLATE_CUBIC); texture->create_from_image(image,tex_flags); texture->set_size_override(Size2(orig_w,orig_h)); } else { texture->create_from_image(image,tex_flags); } if (format==IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS) { texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSLESS); } else { texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY); } texture->set_lossy_storage_quality(quality); } else { Image image=texture->get_data(); ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); bool has_alpha=image.detect_alpha(); if (!has_alpha && image.get_format()==Image::FORMAT_RGBA) { image.convert(Image::FORMAT_RGB); } if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { image.fix_alpha_edges(); } if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_PREMULT_ALPHA) { image.premultiply_alpha(); } if (flags&IMAGE_FLAG_CONVERT_NORMAL_TO_XY) { image.normalmap_to_xy(); } //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {// // print_line("CONVERT BECAUSE: "+itos(flags)); // image.srgb_to_linear(); //} int orig_w=image.get_width(); int orig_h=image.get_height(); if (shrink>1) { image.resize(orig_w/shrink,orig_h/shrink,Image::INTERPOLATE_CUBIC); texture->create_from_image(image,tex_flags);//.........这里部分代码省略.........
开发者ID:BradWBeer,项目名称:godot,代码行数:101,
示例5: Transform2DTransform2D Camera2D::get_camera_transform() { if (!get_tree()) return Transform2D(); ERR_FAIL_COND_V(custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D()); Size2 screen_size = viewport->get_visible_rect().size; Point2 new_camera_pos = get_global_transform().get_origin(); Point2 ret_camera_pos; if (!first) { if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) { if (h_drag_enabled && !Engine::get_singleton()->is_editor_hint()) { camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT])); camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * drag_margin[MARGIN_LEFT])); } else { if (h_ofs < 0) { camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT] * h_ofs; } else { camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_LEFT] * h_ofs; } } if (v_drag_enabled && !Engine::get_singleton()->is_editor_hint()) { camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM])); camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * drag_margin[MARGIN_TOP])); } else { if (v_ofs < 0) { camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_TOP] * v_ofs; } else { camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs; } } } else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) { camera_pos = new_camera_pos; } Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom) : Point2()); Rect2 screen_rect(-screen_offset + camera_pos, screen_size * zoom); if (offset != Vector2()) screen_rect.position += offset; if (limit_smoothing_enabled) { if (screen_rect.position.x < limit[MARGIN_LEFT]) camera_pos.x -= screen_rect.position.x - limit[MARGIN_LEFT]; if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT]) camera_pos.x -= screen_rect.position.x + screen_rect.size.x - limit[MARGIN_RIGHT]; if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM]) camera_pos.y -= screen_rect.position.y + screen_rect.size.y - limit[MARGIN_BOTTOM]; if (screen_rect.position.y < limit[MARGIN_TOP]) camera_pos.y -= screen_rect.position.y - limit[MARGIN_TOP]; } if (smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) { float c = smoothing * get_fixed_process_delta_time(); smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos; ret_camera_pos = smoothed_camera_pos; //camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing; } else { ret_camera_pos = smoothed_camera_pos = camera_pos; } } else { ret_camera_pos = smoothed_camera_pos = camera_pos = new_camera_pos; first = false; } Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom) : Point2()); float angle = get_global_transform().get_rotation(); if (rotating) { screen_offset = screen_offset.rotated(angle); } Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom); if (screen_rect.position.x < limit[MARGIN_LEFT]) screen_rect.position.x = limit[MARGIN_LEFT]; if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT]) screen_rect.position.x = limit[MARGIN_RIGHT] - screen_rect.size.x; if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM]) screen_rect.position.y = limit[MARGIN_BOTTOM] - screen_rect.size.y;//.........这里部分代码省略.........
开发者ID:jejung,项目名称:godot,代码行数:101,
示例6: ERR_FAIL_INDEX_VError HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body) { ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(!p_url.begins_with("/"), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(connection.is_null(), ERR_INVALID_DATA); String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1/r/n"; if ((ssl && conn_port == PORT_HTTPS) || (!ssl && conn_port == PORT_HTTP)) { // Don't append the standard ports request += "Host: " + conn_host + "/r/n"; } else { request += "Host: " + conn_host + ":" + itos(conn_port) + "/r/n"; } bool add_clen = p_body.size() > 0; bool add_uagent = true; bool add_accept = true; for (int i = 0; i < p_headers.size(); i++) { request += p_headers[i] + "/r/n"; if (add_clen && p_headers[i].findn("Content-Length:") == 0) { add_clen = false; } if (add_uagent && p_headers[i].findn("User-Agent:") == 0) { add_uagent = false; } if (add_accept && p_headers[i].findn("Accept:") == 0) { add_accept = false; } } if (add_clen) { request += "Content-Length: " + itos(p_body.size()) + "/r/n"; // Should it add utf8 encoding? } if (add_uagent) { request += "User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")/r/n"; } if (add_accept) { request += "Accept: */*/r/n"; } request += "/r/n"; CharString cs = request.utf8(); PoolVector<uint8_t> data; data.resize(cs.length()); { PoolVector<uint8_t>::Write data_write = data.write(); for (int i = 0; i < cs.length(); i++) { data_write[i] = cs[i]; } } data.append_array(p_body); PoolVector<uint8_t>::Read r = data.read(); Error err = connection->put_data(&r[0], data.size()); if (err) { close(); status = STATUS_CONNECTION_ERROR; return err; } status = STATUS_REQUESTING; return OK;}
开发者ID:93i,项目名称:godot,代码行数:66,
示例7: ERR_FAIL_COND_VPoolByteArray HTTPClient::read_response_body_chunk() { ERR_FAIL_COND_V(status != STATUS_BODY, PoolByteArray()); Error err = OK; if (chunked) { while (true) { if (chunk_left == 0) { // Reading length uint8_t b; int rec = 0; err = _get_http_data(&b, 1, rec); if (rec == 0) break; chunk.push_back(b); if (chunk.size() > 32) { ERR_PRINT("HTTP Invalid chunk hex len"); status = STATUS_CONNECTION_ERROR; return PoolByteArray(); } if (chunk.size() > 2 && chunk[chunk.size() - 2] == '/r' && chunk[chunk.size() - 1] == '/n') { int len = 0; for (int i = 0; i < chunk.size() - 2; i++) { char c = chunk[i]; int v = 0; if (c >= '0' && c <= '9') v = c - '0'; else if (c >= 'a' && c <= 'f') v = c - 'a' + 10; else if (c >= 'A' && c <= 'F') v = c - 'A' + 10; else { ERR_PRINT("HTTP Chunk len not in hex!!"); status = STATUS_CONNECTION_ERROR; return PoolByteArray(); } len <<= 4; len |= v; if (len > (1 << 24)) { ERR_PRINT("HTTP Chunk too big!! >16mb"); status = STATUS_CONNECTION_ERROR; return PoolByteArray(); } } if (len == 0) { // End reached! status = STATUS_CONNECTED; chunk.clear(); return PoolByteArray(); } chunk_left = len + 2; chunk.resize(chunk_left); } } else { int rec = 0; err = _get_http_data(&chunk.write[chunk.size() - chunk_left], chunk_left, rec); if (rec == 0) { break; } chunk_left -= rec; if (chunk_left == 0) { if (chunk[chunk.size() - 2] != '/r' || chunk[chunk.size() - 1] != '/n') { ERR_PRINT("HTTP Invalid chunk terminator (not //r//n)"); status = STATUS_CONNECTION_ERROR; return PoolByteArray(); } PoolByteArray ret; ret.resize(chunk.size() - 2); { PoolByteArray::Write w = ret.write(); copymem(w.ptr(), chunk.ptr(), chunk.size() - 2); } chunk.clear(); return ret; } break; } } } else { int to_read = !read_until_eof ? MIN(body_left, read_chunk_size) : read_chunk_size; PoolByteArray ret; ret.resize(to_read);//.........这里部分代码省略.........
开发者ID:93i,项目名称:godot,代码行数:101,
示例8: ERR_FAIL_COND_VVariant Object::get_meta(const String& p_name) const { ERR_FAIL_COND_V(!metadata.has(p_name),Variant()); return metadata[p_name];}
开发者ID:hellaguy130,项目名称:godot,代码行数:5,
示例9: ERR_FAIL_COND_VMutex *Mutex::create(bool p_recursive) { ERR_FAIL_COND_V( !create_func, 0 ); return create_func(p_recursive);}
开发者ID:AwsomeGameEngine,项目名称:godot,代码行数:6,
示例10: ERR_FAIL_COND_VArray VoxelMesher::build(const VoxelBuffer &buffer, unsigned int channel, Vector3i min, Vector3i max) { uint64_t time_before = OS::get_singleton()->get_ticks_usec(); ERR_FAIL_COND_V(_library.is_null(), Array()); ERR_FAIL_COND_V(channel >= VoxelBuffer::MAX_CHANNELS, Array()); const VoxelLibrary &library = **_library; for (unsigned int i = 0; i < MAX_MATERIALS; ++i) { Arrays &a = _arrays[i]; a.positions.clear(); a.normals.clear(); a.uvs.clear(); a.colors.clear(); a.indices.clear(); } float baked_occlusion_darkness; if (_bake_occlusion) baked_occlusion_darkness = _baked_occlusion_darkness / 3.0; // The technique is Culled faces. // Could be improved with greedy meshing: https://0fps.net/2012/06/30/meshing-in-a-minecraft-game/ // However I don't feel it's worth it yet: // - Not so much gain for organic worlds with lots of texture variations // - Works well with cubes but not with any shape // - Slower // => Could be implemented in a separate class? // Data must be padded, hence the off-by-one Vector3i::sort_min_max(min, max); const Vector3i pad(1, 1, 1); min.clamp_to(pad, max); max.clamp_to(min, buffer.get_size() - pad); int index_offset = 0; // Iterate 3D padded data to extract voxel faces. // This is the most intensive job in this class, so all required data should be as fit as possible. // The buffer we receive MUST be dense (i.e not compressed, and channels allocated). // That means we can use raw pointers to voxel data inside instead of using the higher-level getters, // and then save a lot of time. uint8_t *type_buffer = buffer.get_channel_raw(Voxel::CHANNEL_TYPE); // _ // | / // // // // / /|/// // | |/ /// // | /_/ //| // | | ) // / | | // / / CRASH_COND(type_buffer == NULL); //CRASH_COND(memarr_len(type_buffer) != buffer.get_volume() * sizeof(uint8_t)); // Build lookup tables so to speed up voxel access. // These are values to add to an address in order to get given neighbor. int row_size = buffer.get_size().y; int deck_size = buffer.get_size().x * row_size; int side_neighbor_lut[Cube::SIDE_COUNT]; side_neighbor_lut[Cube::SIDE_LEFT] = row_size; side_neighbor_lut[Cube::SIDE_RIGHT] = -row_size; side_neighbor_lut[Cube::SIDE_BACK] = -deck_size; side_neighbor_lut[Cube::SIDE_FRONT] = deck_size; side_neighbor_lut[Cube::SIDE_BOTTOM] = -1; side_neighbor_lut[Cube::SIDE_TOP] = 1; int edge_neighbor_lut[Cube::EDGE_COUNT]; edge_neighbor_lut[Cube::EDGE_BOTTOM_BACK] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_BACK]; edge_neighbor_lut[Cube::EDGE_BOTTOM_FRONT] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_FRONT]; edge_neighbor_lut[Cube::EDGE_BOTTOM_LEFT] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_LEFT]; edge_neighbor_lut[Cube::EDGE_BOTTOM_RIGHT] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_RIGHT]; edge_neighbor_lut[Cube::EDGE_BACK_LEFT] = side_neighbor_lut[Cube::SIDE_BACK] + side_neighbor_lut[Cube::SIDE_LEFT]; edge_neighbor_lut[Cube::EDGE_BACK_RIGHT] = side_neighbor_lut[Cube::SIDE_BACK] + side_neighbor_lut[Cube::SIDE_RIGHT]; edge_neighbor_lut[Cube::EDGE_FRONT_LEFT] = side_neighbor_lut[Cube::SIDE_FRONT] + side_neighbor_lut[Cube::SIDE_LEFT]; edge_neighbor_lut[Cube::EDGE_FRONT_RIGHT] = side_neighbor_lut[Cube::SIDE_FRONT] + side_neighbor_lut[Cube::SIDE_RIGHT]; edge_neighbor_lut[Cube::EDGE_TOP_BACK] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_BACK]; edge_neighbor_lut[Cube::EDGE_TOP_FRONT] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_FRONT]; edge_neighbor_lut[Cube::EDGE_TOP_LEFT] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_LEFT]; edge_neighbor_lut[Cube::EDGE_TOP_RIGHT] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_RIGHT]; int corner_neighbor_lut[Cube::CORNER_COUNT]; corner_neighbor_lut[Cube::CORNER_BOTTOM_BACK_LEFT] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_BACK] + side_neighbor_lut[Cube::SIDE_LEFT]; corner_neighbor_lut[Cube::CORNER_BOTTOM_BACK_RIGHT] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_BACK] + side_neighbor_lut[Cube::SIDE_RIGHT]; corner_neighbor_lut[Cube::CORNER_BOTTOM_FRONT_RIGHT] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_FRONT] + side_neighbor_lut[Cube::SIDE_RIGHT]; corner_neighbor_lut[Cube::CORNER_BOTTOM_FRONT_LEFT] = side_neighbor_lut[Cube::SIDE_BOTTOM] + side_neighbor_lut[Cube::SIDE_FRONT] + side_neighbor_lut[Cube::SIDE_LEFT]; corner_neighbor_lut[Cube::CORNER_TOP_BACK_LEFT] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_BACK] + side_neighbor_lut[Cube::SIDE_LEFT]; corner_neighbor_lut[Cube::CORNER_TOP_BACK_RIGHT] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_BACK] + side_neighbor_lut[Cube::SIDE_RIGHT]; corner_neighbor_lut[Cube::CORNER_TOP_FRONT_RIGHT] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_FRONT] + side_neighbor_lut[Cube::SIDE_RIGHT]; corner_neighbor_lut[Cube::CORNER_TOP_FRONT_LEFT] = side_neighbor_lut[Cube::SIDE_TOP] + side_neighbor_lut[Cube::SIDE_FRONT] + side_neighbor_lut[Cube::SIDE_LEFT]; uint64_t time_prep = OS::get_singleton()->get_ticks_usec() - time_before; time_before = OS::get_singleton()->get_ticks_usec();//.........这里部分代码省略.........
开发者ID:Zylann,项目名称:godot_voxel,代码行数:101,
示例11: ERR_FAIL_COND_Vbool Main::start() { ERR_FAIL_COND_V(!_start_success,false); bool editor=false; String doc_tool; bool doc_base=true; String game_path; String script; String test; String screen; String optimize; String optimize_preset; String _export_platform; String _import; String _import_script; String dumpstrings; bool noquit=false; bool convert_old=false; bool export_debug=false; List<String> args = OS::get_singleton()->get_cmdline_args(); for (int i=0;i<args.size();i++) { if (args[i]=="-doctool" && i <(args.size()-1)) { doc_tool=args[i+1]; i++; }else if (args[i]=="-nodocbase") { doc_base=false; } else if ((args[i]=="-script" || args[i]=="-s") && i <(args.size()-1)) { script=args[i+1]; i++; } else if ((args[i]=="-level" || args[i]=="-l") && i <(args.size()-1)) { OS::get_singleton()->_custom_level=args[i+1]; i++; } else if (args[i]=="-test" && i <(args.size()-1)) { test=args[i+1]; i++; } else if (args[i]=="-optimize" && i <(args.size()-1)) { optimize=args[i+1]; i++; } else if (args[i]=="-optimize_preset" && i <(args.size()-1)) { optimize_preset=args[i+1]; i++; } else if (args[i]=="-export" && i <(args.size()-1)) { editor=true; //needs editor _export_platform=args[i+1]; i++; } else if (args[i]=="-export_debug" && i <(args.size()-1)) { editor=true; //needs editor _export_platform=args[i+1]; export_debug=true; i++; } else if (args[i]=="-import" && i <(args.size()-1)) { editor=true; //needs editor _import=args[i+1]; i++; } else if (args[i]=="-import_script" && i <(args.size()-1)) { editor=true; //needs editor _import_script=args[i+1]; i++; } else if (args[i]=="-noquit" ) { noquit=true; } else if (args[i]=="-dumpstrings" && i <(args.size()-1)) { editor=true; //needs editor dumpstrings=args[i+1]; i++; } else if (args[i]=="-editor" || args[i]=="-e") { editor=true; } else if (args[i]=="-convert_old") { convert_old=true; } else if (args[i].length() && args[i][0] != '-' && game_path == "") { game_path=args[i]; } } if (editor) Globals::get_singleton()->set("editor_active",true); String main_loop_type;#ifdef TOOLS_ENABLED if(doc_tool!="") { DocData doc; doc.generate(doc_base); DocData docsrc; if (docsrc.load(doc_tool)==OK) { print_line("Doc exists. Merging.."); doc.merge_from(docsrc); } else { print_line("No Doc exists. Generating empty."); }//.........这里部分代码省略.........
开发者ID:hitjim,项目名称:godot,代码行数:101,
示例12: while//.........这里部分代码省略......... }; token_array.push_back(token); if (tt.get_token()==TK_EOF) break; tt.advance(); } //reverse maps Map<int,StringName> rev_identifier_map; for(Map<StringName,int>::Element *E=identifier_map.front();E;E=E->next()) { rev_identifier_map[E->get()]=E->key(); } Map<int,Variant> rev_constant_map; const Variant *K =NULL; while((K=constant_map.next(K))) { rev_constant_map[constant_map[*K]]=*K; } Map<int,uint32_t> rev_line_map; for(Map<uint32_t,int>::Element *E=line_map.front();E;E=E->next()) { rev_line_map[E->get()]=E->key(); } //save header buf.resize(24); buf[0]='G'; buf[1]='D'; buf[2]='S'; buf[3]='C'; encode_uint32(BYTECODE_VERSION,&buf[4]); encode_uint32(identifier_map.size(),&buf[8]); encode_uint32(constant_map.size(),&buf[12]); encode_uint32(line_map.size(),&buf[16]); encode_uint32(token_array.size(),&buf[20]); //save identifiers for(Map<int,StringName>::Element *E=rev_identifier_map.front();E;E=E->next()) { CharString cs = String(E->get()).utf8(); int len = cs.length()+1; int extra = 4-(len%4); if (extra==4) extra=0; uint8_t ibuf[4]; encode_uint32(len+extra,ibuf); for(int i=0;i<4;i++) { buf.push_back(ibuf[i]); } for(int i=0;i<len;i++) { buf.push_back(cs[i]^0xb6); } for(int i=0;i<extra;i++) { buf.push_back(0^0xb6); } } for(Map<int,Variant>::Element *E=rev_constant_map.front();E;E=E->next()) { int len; Error err = encode_variant(E->get(),NULL,len); ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>()); int pos=buf.size(); buf.resize(pos+len); encode_variant(E->get(),&buf[pos],len); } for(Map<int,uint32_t>::Element *E=rev_line_map.front();E;E=E->next()) { uint8_t ibuf[8]; encode_uint32(E->key(),&ibuf[0]); encode_uint32(E->get(),&ibuf[4]); for(int i=0;i<8;i++) buf.push_back(ibuf[i]); } for(int i=0;i<token_array.size();i++) { uint32_t token = token_array[i]; if (token&~TOKEN_MASK) { uint8_t buf4[4]; encode_uint32(token_array[i]|TOKEN_BYTE_MASK,&buf4[0]); for(int j=0;j<4;j++) { buf.push_back(buf4[j]); } } else { buf.push_back(token); } } return buf;}
开发者ID:baekdahl,项目名称:godot,代码行数:101,
示例13: ERR_FAIL_COND_VError GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) { const uint8_t *buf=p_buffer.ptr(); int total_len=p_buffer.size(); ERR_FAIL_COND_V( p_buffer.size()<24 || p_buffer[0]!='G' || p_buffer[1]!='D' || p_buffer[2]!='S' || p_buffer[3]!='C',ERR_INVALID_DATA); int version = decode_uint32(&buf[4]); if (version>BYTECODE_VERSION) { ERR_EXPLAIN("Bytecode is too New! Please use a newer engine version."); ERR_FAIL_COND_V(version>BYTECODE_VERSION,ERR_INVALID_DATA); } int identifier_count = decode_uint32(&buf[8]); int constant_count = decode_uint32(&buf[12]); int line_count = decode_uint32(&buf[16]); int token_count = decode_uint32(&buf[20]); const uint8_t *b=buf; b=&buf[24]; total_len-=24; identifiers.resize(identifier_count); for(int i=0;i<identifier_count;i++) { int len = decode_uint32(b); ERR_FAIL_COND_V(len>total_len,ERR_INVALID_DATA); b+=4; Vector<uint8_t> cs; cs.resize(len); for(int j=0;j<len;j++) { cs[j]=b[j]^0xb6; } cs[cs.size()-1]=0; String s; s.parse_utf8((const char*)cs.ptr()); b+=len; total_len-=len+4; identifiers[i]=s; } constants.resize(constant_count); for(int i=0;i<constant_count;i++) { Variant v; int len; Error err = decode_variant(v,b,total_len,&len); if (err) return err; b+=len; total_len-=len; constants[i]=v; } ERR_FAIL_COND_V(line_count*8>total_len,ERR_INVALID_DATA); for(int i=0;i<line_count;i++) { uint32_t token=decode_uint32(b); b+=4; uint32_t linecol=decode_uint32(b); b+=4; lines.insert(token,linecol); total_len-=8; } tokens.resize(token_count); for(int i=0;i<token_count;i++) { ERR_FAIL_COND_V( total_len < 1, ERR_INVALID_DATA); if ((*b)&TOKEN_BYTE_MASK) { //little endian always ERR_FAIL_COND_V( total_len < 4, ERR_INVALID_DATA); tokens[i]=decode_uint32(b)&~TOKEN_BYTE_MASK; b+=4; } else { tokens[i]=*b; b+=1; total_len--; } } token=0; return OK;}
开发者ID:baekdahl,项目名称:godot,代码行数:92,
示例14: ERR_FAIL_COND_Vfloat AnimationPlayer::get_current_animation_length() const { ERR_FAIL_COND_V(!playback.current.from,0); return playback.current.from->animation->get_length();}
开发者ID:RichardMarks,项目名称:godot,代码行数:5,
示例15: ERR_FAIL_COND_VRef<World> Spatial::get_world() const { ERR_FAIL_COND_V(!is_inside_world(),Ref<World>()); return data.viewport->find_world();}
开发者ID:n-pigeon,项目名称:godot,代码行数:6,
示例16: _connect_facesDVector<DVector<Face3> > Geometry::separate_objects(DVector<Face3> p_array) { DVector<DVector<Face3> > objects; int len = p_array.size(); DVector<Face3>::Read r = p_array.read(); const Face3 *arrayptr = r.ptr(); DVector<_FaceClassify> fc; fc.resize(len); DVector<_FaceClassify>::Write fcw = fc.write(); _FaceClassify *_fcptr = fcw.ptr(); for (int i = 0; i < len; i++) { _fcptr[i].face = arrayptr[i]; } bool error = _connect_faces(_fcptr, len, -1); if (error) { ERR_FAIL_COND_V(error, DVector<DVector<Face3> >()); // invalid geometry } /* group connected faces in separate objects */ int group = 0; for (int i = 0; i < len; i++) { if (!_fcptr[i].valid) continue; if (_group_face(_fcptr, len, i, group)) { group++; } } /* group connected faces in separate objects */ for (int i = 0; i < len; i++) { _fcptr[i].face = arrayptr[i]; } if (group >= 0) { objects.resize(group); DVector<DVector<Face3> >::Write obw = objects.write(); DVector<Face3> *group_faces = obw.ptr(); for (int i = 0; i < len; i++) { if (!_fcptr[i].valid) continue; if (_fcptr[i].group >= 0 && _fcptr[i].group < group) { group_faces[_fcptr[i].group].push_back(_fcptr[i].face); } } } return objects;}
开发者ID:allkhor,项目名称:godot,代码行数:67,
示例17: ERR_FAIL_COND_Vint MultiplayerAPI::get_network_unique_id() const { ERR_FAIL_COND_V(!network_peer.is_valid(), 0); return network_peer->get_unique_id();}
开发者ID:marcelofg55,项目名称:godot,代码行数:5,
示例18: switchError HTTPClient::poll() { switch (status) { case STATUS_RESOLVING: { ERR_FAIL_COND_V(resolving == IP::RESOLVER_INVALID_ID, ERR_BUG); IP::ResolverStatus rstatus = IP::get_singleton()->get_resolve_item_status(resolving); switch (rstatus) { case IP::RESOLVER_STATUS_WAITING: return OK; // Still resolving case IP::RESOLVER_STATUS_DONE: { IP_Address host = IP::get_singleton()->get_resolve_item_address(resolving); Error err = tcp_connection->connect_to_host(host, conn_port); IP::get_singleton()->erase_resolve_item(resolving); resolving = IP::RESOLVER_INVALID_ID; if (err) { status = STATUS_CANT_CONNECT; return err; } status = STATUS_CONNECTING; } break; case IP::RESOLVER_STATUS_NONE: case IP::RESOLVER_STATUS_ERROR: { IP::get_singleton()->erase_resolve_item(resolving); resolving = IP::RESOLVER_INVALID_ID; close(); status = STATUS_CANT_RESOLVE; return ERR_CANT_RESOLVE; } break; } } break; case STATUS_CONNECTING: { StreamPeerTCP::Status s = tcp_connection->get_status(); switch (s) { case StreamPeerTCP::STATUS_CONNECTING: { return OK; } break; case StreamPeerTCP::STATUS_CONNECTED: { if (ssl) { Ref<StreamPeerSSL> ssl; if (!handshaking) { // Connect the StreamPeerSSL and start handshaking ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create()); ssl->set_blocking_handshake_enabled(false); Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, conn_host); if (err != OK) { close(); status = STATUS_SSL_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } connection = ssl; handshaking = true; } else { // We are already handshaking, which means we can use your already active SSL connection ssl = static_cast<Ref<StreamPeerSSL> >(connection); ssl->poll(); // Try to finish the handshake } if (ssl->get_status() == StreamPeerSSL::STATUS_CONNECTED) { // Handshake has been successful handshaking = false; status = STATUS_CONNECTED; return OK; } else if (ssl->get_status() != StreamPeerSSL::STATUS_HANDSHAKING) { // Handshake has failed close(); status = STATUS_SSL_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } // ... we will need to poll more for handshake to finish } else { status = STATUS_CONNECTED; } return OK; } break; case StreamPeerTCP::STATUS_ERROR: case StreamPeerTCP::STATUS_NONE: { close(); status = STATUS_CANT_CONNECT; return ERR_CANT_CONNECT; } break; } } break; case STATUS_BODY: case STATUS_CONNECTED: { // Check if we are still connected if (ssl) { Ref<StreamPeerSSL> tmp = connection; tmp->poll(); if (tmp->get_status() != StreamPeerSSL::STATUS_CONNECTED) { status = STATUS_CONNECTION_ERROR; return ERR_CONNECTION_ERROR;//.........这里部分代码省略.........
开发者ID:93i,项目名称:godot,代码行数:101,
示例19: ERR_FAIL_COND_Vvoid* MemoryPoolStaticMalloc::_alloc(size_t p_bytes,const char *p_description) { ERR_FAIL_COND_V(p_bytes==0,0); MutexLock lock(mutex); #ifdef DEBUG_MEMORY_ENABLED size_t total; #if defined(_add_overflow) if (_add_overflow(p_bytes, sizeof(RingPtr), &total)) return NULL; #else total = p_bytes + sizeof(RingPtr); #endif void *mem=malloc(total); /// add for size and ringlist if (!mem) { printf("**ERROR: out of memory while allocating %lu bytes by %s?/n", (unsigned long) p_bytes, p_description); printf("**ERROR: memory usage is %lu/n", (unsigned long) get_total_usage()); }; ERR_FAIL_COND_V(!mem,0); //out of memory, or unreasonable request /* setup the ringlist element */ RingPtr *ringptr = (RingPtr*)mem; /* setup the ringlist element data (description and size ) */ ringptr->size = p_bytes; ringptr->descr=p_description; if (ringlist) { /* existing ringlist */ /* assign next */ ringptr->next = ringlist->next; ringlist->next = ringptr; /* assign prev */ ringptr->prev = ringlist; ringptr->next->prev = ringptr; } else { /* non existing ringlist */ ringptr->next=ringptr; ringptr->prev=ringptr; ringlist=ringptr; } total_mem+=p_bytes; /* update statistics */ if (total_mem > max_mem ) max_mem = total_mem; total_pointers++; if (total_pointers > max_pointers) max_pointers=total_pointers; return ringptr + 1; /* return memory after ringptr */ #else void *mem=malloc(p_bytes); ERR_FAIL_COND_V(!mem,0); //out of memory, or unreasonable request return mem; #endif }
开发者ID:03050903,项目名称:godot,代码行数:68,
示例20: memnewNode *Node::duplicate(bool p_use_instancing) const { Node *node=NULL; bool instanced=false; if (cast_to<InstancePlaceholder>()) { const InstancePlaceholder *ip = cast_to<const InstancePlaceholder>(); InstancePlaceholder *nip = memnew( InstancePlaceholder ); nip->set_instance_path( ip->get_instance_path() ); node=nip; } else if (p_use_instancing && get_filename()!=String()) { Ref<PackedScene> res = ResourceLoader::load(get_filename()); ERR_FAIL_COND_V(res.is_null(),NULL); node=res->instance(); ERR_FAIL_COND_V(!node,NULL); instanced=true; } else { Object *obj = ObjectTypeDB::instance(get_type()); ERR_FAIL_COND_V(!obj,NULL); node = obj->cast_to<Node>(); if (!node) memdelete(obj); ERR_FAIL_COND_V(!node,NULL); } if (get_filename()!="") { //an instance node->set_filename(get_filename()); } List<PropertyInfo> plist; get_property_list(&plist); for(List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) { if (!(E->get().usage&PROPERTY_USAGE_STORAGE)) continue; String name = E->get().name; node->set( name, get(name) ); } node->set_name(get_name()); List<GroupInfo> gi; get_groups(&gi); for (List<GroupInfo>::Element *E=gi.front();E;E=E->next()) { node->add_to_group(E->get().name, E->get().persistent); } _duplicate_signals(this, node); for(int i=0;i<get_child_count();i++) { if (get_child(i)->data.parent_owned) continue; if (instanced && get_child(i)->data.owner==this) continue; //part of instance Node *dup = get_child(i)->duplicate(p_use_instancing); if (!dup) { memdelete(node); return NULL; } node->add_child(dup); } return node;}
开发者ID:P-GLEZ,项目名称:godot,代码行数:81,
示例21: ERR_FAIL_COND_VPoolAllocator::ID PoolAllocator::alloc(int p_size) { ERR_FAIL_COND_V(p_size<1,POOL_ALLOCATOR_INVALID_ID);#ifdef DEBUG_ENABLED if (p_size > free_mem) OS::get_singleton()->debug_break();#endif ERR_FAIL_COND_V(p_size>free_mem,POOL_ALLOCATOR_INVALID_ID); mt_lock(); if (entry_count==entry_max) { mt_unlock(); ERR_PRINT("entry_count==entry_max"); return POOL_ALLOCATOR_INVALID_ID; } int size_to_alloc=aligned(p_size); EntryIndicesPos new_entry_indices_pos; if (!find_hole(&new_entry_indices_pos, size_to_alloc)) { /* No hole could be found, try compacting mem */ compact(); /* Then search again */ if (!find_hole(&new_entry_indices_pos, size_to_alloc)) { mt_unlock(); ERR_PRINT("memory can't be compacted further"); return POOL_ALLOCATOR_INVALID_ID; } } EntryArrayPos new_entry_array_pos; bool found_free_entry=get_free_entry(&new_entry_array_pos); if (!found_free_entry) { mt_unlock(); ERR_FAIL_COND_V( !found_free_entry , POOL_ALLOCATOR_INVALID_ID ); } /* move all entry indices up, make room for this one */ for (int i=entry_count;i>new_entry_indices_pos;i-- ) { entry_indices[i]=entry_indices[i-1]; } entry_indices[new_entry_indices_pos]=new_entry_array_pos; entry_count++; Entry &entry=entry_array[ entry_indices[ new_entry_indices_pos ] ]; entry.len=p_size; entry.pos=(new_entry_indices_pos==0)?0:entry_end(entry_array[ entry_indices[ new_entry_indices_pos-1 ] ]); //alloc either at begining or end of previous entry.lock=0; entry.check=(check_count++)&CHECK_MASK; free_mem-=size_to_alloc; if (free_mem<free_mem_peak) free_mem_peak=free_mem; ID retval = (entry_indices[ new_entry_indices_pos ]<<CHECK_BITS)|entry.check; mt_unlock(); //ERR_FAIL_COND_V( (uintptr_t)get(retval)%align != 0, retval ); return retval;}
开发者ID:111X,项目名称:godot,代码行数:71,
示例22: ERR_FAIL_NULL_Vbool Node::is_greater_than(const Node *p_node) const { ERR_FAIL_NULL_V(p_node,false); ERR_FAIL_COND_V( !data.inside_tree, false ); ERR_FAIL_COND_V( !p_node->data.inside_tree, false ); ERR_FAIL_COND_V( data.depth<0, false); ERR_FAIL_COND_V( p_node->data.depth<0, false);#ifdef NO_ALLOCA Vector<int> this_stack; Vector<int> that_stack; this_stack.resize(data.depth); that_stack.resize(p_node->data.depth);#else int *this_stack=(int*)alloca(sizeof(int)*data.depth); int *that_stack=(int*)alloca(sizeof(int)*p_node->data.depth);#endif const Node *n = this; int idx=data.depth-1; while(n) { ERR_FAIL_INDEX_V(idx, data.depth,false); this_stack[idx--]=n->data.pos; n=n->data.parent; } ERR_FAIL_COND_V(idx!=-1,false); n = p_node; idx=p_node->data.depth-1; while(n) { ERR_FAIL_INDEX_V(idx, p_node->data.depth,false); that_stack[idx--]=n->data.pos; n=n->data.parent; } ERR_FAIL_COND_V(idx!=-1,false); idx=0; bool res; while(true) { // using -2 since out-of-tree or nonroot nodes have -1 int this_idx = (idx >= data.depth)? -2 : this_stack[idx]; int that_idx = (idx >= p_node->data.depth)? -2 : that_stack[idx]; if (this_idx > that_idx) { res=true; break; } else if (this_idx < that_idx) { res=false; break; } else if (this_idx == -2 ) { res=false; // equal break; } idx++; } return res;}
开发者ID:P-GLEZ,项目名称:godot,代码行数:64,
示例23: ERR_FAIL_COND_Vint BroadPhase2DHashGrid::get_subindex(ID p_id) const { const Map<ID,Element>::Element *E=element_map.find(p_id); ERR_FAIL_COND_V(!E,-1); return E->get().subindex;}
开发者ID:19Staceys,项目名称:godot,代码行数:6,
示例24: memnewError ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_resource,uint32_t p_flags) { Error err; if (p_flags&ResourceSaver::FLAG_COMPRESS) { FileAccessCompressed *fac = memnew( FileAccessCompressed ); fac->configure("RSCC"); f=fac; err = fac->_open(p_path,FileAccess::WRITE); if (err) memdelete(f); } else { f=FileAccess::open(p_path,FileAccess::WRITE,&err); } ERR_FAIL_COND_V(err,err); FileAccessRef _fref(f); relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS; skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES; big_endian=p_flags&ResourceSaver::FLAG_SAVE_BIG_ENDIAN; no_extensions=p_flags&ResourceSaver::FLAG_NO_EXTENSION; local_path=p_path.get_base_dir(); //bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create _find_resources(p_resource,true); if (!(p_flags&ResourceSaver::FLAG_COMPRESS)) { //save header compressed static const uint8_t header[4]={'R','S','R','C'}; f->store_buffer(header,4); } if (big_endian) { f->store_32(1); f->set_endian_swap(true); } else f->store_32(0); f->store_32(0); //64 bits file, false for now f->store_32(VERSION_MAJOR); f->store_32(VERSION_MINOR); f->store_32(FORMAT_VERSION); //f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed save_unicode_string(p_resource->get_type()); uint64_t md_at = f->get_pos(); f->store_64(0); //offset to impoty metadata for(int i=0;i<14;i++) f->store_32(0); // reserved List<ResourceData> resources; { for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) { ResourceData &rd = resources.push_back(ResourceData())->get(); rd.type=E->get()->get_type(); List<PropertyInfo> property_list; E->get()->get_property_list( &property_list ); for(List<PropertyInfo>::Element *F=property_list.front();F;F=F->next()) { if (skip_editor && F->get().name.begins_with("__editor")) continue; if (F->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && F->get().usage&PROPERTY_USAGE_BUNDLE)) { Property p; p.name_idx=get_string_index(F->get().name); p.value=E->get()->get(F->get().name); if (F->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && p.value.is_zero()) continue; p.pi=F->get(); rd.properties.push_back(p); } } } } f->store_32(strings.size()); //string table size for(int i=0;i<strings.size();i++) { //print_bl("saving string: "+strings[i]); save_unicode_string(strings[i]); }//.........这里部分代码省略.........
开发者ID:0871087123,项目名称:godot,代码行数:101,
注:本文中的ERR_FAIL_COND_V函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ERR_FAIL_INDEX_V函数代码示例 C++ ERR_FAIL函数代码示例 |