当前位置: 首页>>代码示例>>C++>>正文


C++ PoolVector::size方法代码示例

本文整理汇总了C++中PoolVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ PoolVector::size方法的具体用法?C++ PoolVector::size怎么用?C++ PoolVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PoolVector的用法示例。


在下文中一共展示了PoolVector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _get_partial_data

Array StreamPeer::_get_partial_data(int p_bytes) {

	Array ret;

	PoolVector<uint8_t> data;
	data.resize(p_bytes);
	if (data.size() != p_bytes) {

		ret.push_back(ERR_OUT_OF_MEMORY);
		ret.push_back(PoolVector<uint8_t>());
		return ret;
	}

	PoolVector<uint8_t>::Write w = data.write();
	int received;
	Error err = get_partial_data(&w[0], p_bytes, received);
	w = PoolVector<uint8_t>::Write();

	if (err != OK) {
		data.resize(0);
	} else if (received != data.size()) {

		data.resize(received);
	}

	ret.push_back(err);
	ret.push_back(data);
	return ret;
}
开发者ID:Bonfi96,项目名称:godot,代码行数:29,代码来源:stream_peer.cpp

示例2: load

RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String &p_original_path, Error *r_error) {

	if (r_error)
		*r_error = ERR_FILE_CANT_OPEN;

	FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
	ERR_FAIL_COND_V(!f, RES());

	PoolVector<uint8_t> data;

	data.resize(f->get_len());

	ERR_FAIL_COND_V(data.size() == 0, RES());

	{
		PoolVector<uint8_t>::Write w = data.write();
		f->get_buffer(w.ptr(), data.size());
	}

	Ref<DynamicFontData> dfd;
	dfd.instance();
	dfd->set_font_data(data);

	if (r_error)
		*r_error = OK;

	return dfd;
}
开发者ID:KelinciFX,项目名称:godot,代码行数:28,代码来源:dynamic_font_stb.cpp

示例3: canvas_occluder_polygon_set_shape

void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape, bool p_closed) {

	if (p_shape.size() < 3) {
		canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, p_shape);
		return;
	}

	PoolVector<Vector2> lines;
	int lc = p_shape.size() * 2;

	lines.resize(lc - (p_closed ? 0 : 2));
	{
		PoolVector<Vector2>::Write w = lines.write();
		PoolVector<Vector2>::Read r = p_shape.read();

		int max = lc / 2;
		if (!p_closed) {
			max--;
		}
		for (int i = 0; i < max; i++) {

			Vector2 a = r[i];
			Vector2 b = r[(i + 1) % (lc / 2)];
			w[i * 2 + 0] = a;
			w[i * 2 + 1] = b;
		}
	}

	canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, lines);
}
开发者ID:MattUV,项目名称:godot,代码行数:30,代码来源:visual_server_canvas.cpp

示例4: create_from_mesh

void NavigationMesh::create_from_mesh(const Ref<Mesh>& p_mesh) {


	vertices=PoolVector<Vector3>();
	clear_polygons();

	for(int i=0;i<p_mesh->get_surface_count();i++) {

		if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
			continue;
		Array arr = p_mesh->surface_get_arrays(i);
		PoolVector<Vector3> varr = arr[Mesh::ARRAY_VERTEX];
		PoolVector<int> iarr = arr[Mesh::ARRAY_INDEX];
		if (varr.size()==0 || iarr.size()==0)
			continue;

		int from = vertices.size();
		vertices.append_array(varr);
		int rlen = iarr.size();
		PoolVector<int>::Read r = iarr.read();

		for(int j=0;j<rlen;j+=3) {
			Vector<int> vi;
			vi.resize(3);
			vi[0]=r[j+0]+from;
			vi[1]=r[j+1]+from;
			vi[2]=r[j+2]+from;

			add_polygon(vi);
		}
	}
}
开发者ID:baekdahl,项目名称:godot,代码行数:32,代码来源:navigation_mesh.cpp

示例5: request_raw

Error 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(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
	ERR_FAIL_COND_V(connection.is_null(), ERR_INVALID_DATA);

	static const char *_methods[METHOD_MAX] = {
		"GET",
		"HEAD",
		"POST",
		"PUT",
		"DELETE",
		"OPTIONS",
		"TRACE",
		"CONNECT"
	};

	String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n";
	if ((ssl && conn_port == 443) || (!ssl && conn_port == 80)) {
		// 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;
	for (int i = 0; i < p_headers.size(); i++) {
		request += p_headers[i] + "\r\n";
		if (add_clen && p_headers[i].find("Content-Length:") == 0) {
			add_clen = false;
		}
	}
	if (add_clen) {
		request += "Content-Length: " + itos(p_body.size()) + "\r\n";
		//should it add utf8 encoding? not sure
	}
	request += "\r\n";
	CharString cs = request.utf8();

	PoolVector<uint8_t> data;

	//Maybe this goes faster somehow?
	for (int i = 0; i < cs.length(); i++) {
		data.append(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:KelinciFX,项目名称:godot,代码行数:59,代码来源:http_client.cpp

示例6: send_bytes

Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to) {

	ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_DATA);
	ERR_FAIL_COND_V(!network_peer.is_valid(), ERR_UNCONFIGURED);
	ERR_FAIL_COND_V(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED);

	MAKE_ROOM(p_data.size() + 1);
	PoolVector<uint8_t>::Read r = p_data.read();
	packet_cache[0] = NETWORK_COMMAND_RAW;
	memcpy(&packet_cache[1], &r[0], p_data.size());
	network_peer->set_target_peer(p_to);
	return network_peer->put_packet(packet_cache.ptr(), p_data.size() + 1);
}
开发者ID:laverneth,项目名称:godot,代码行数:13,代码来源:multiplayer_api.cpp

示例7: _set_data

void PolygonPathFinder::_set_data(const Dictionary &p_data) {

	ERR_FAIL_COND(!p_data.has("points"));
	ERR_FAIL_COND(!p_data.has("connections"));
	ERR_FAIL_COND(!p_data.has("segments"));
	ERR_FAIL_COND(!p_data.has("bounds"));

	PoolVector<Vector2> p = p_data["points"];
	Array c = p_data["connections"];

	ERR_FAIL_COND(c.size() != p.size());
	if (c.size())
		return;

	int pc = p.size();
	points.resize(pc + 2);

	PoolVector<Vector2>::Read pr = p.read();
	for (int i = 0; i < pc; i++) {
		points.write[i].pos = pr[i];
		PoolVector<int> con = c[i];
		PoolVector<int>::Read cr = con.read();
		int cc = con.size();
		for (int j = 0; j < cc; j++) {

			points.write[i].connections.insert(cr[j]);
		}
	}

	if (p_data.has("penalties")) {

		PoolVector<float> penalties = p_data["penalties"];
		if (penalties.size() == pc) {
			PoolVector<float>::Read pr = penalties.read();
			for (int i = 0; i < pc; i++) {
				points.write[i].penalty = pr[i];
			}
		}
	}

	PoolVector<int> segs = p_data["segments"];
	int sc = segs.size();
	ERR_FAIL_COND(sc & 1);
	PoolVector<int>::Read sr = segs.read();
	for (int i = 0; i < sc; i += 2) {

		Edge e(sr[i], sr[i + 1]);
		edges.insert(e);
	}
	bounds = p_data["bounds"];
}
开发者ID:93i,项目名称:godot,代码行数:51,代码来源:polygon_path_finder.cpp

示例8: _get_number_from_token

static int _get_number_from_token(PoolVector<uint8_t>& r_token) {

	int len = r_token.size();
	PoolVector<uint8_t>::Read r = r_token.read();
	return String::to_int((const char*)r.ptr(),len);

}
开发者ID:baekdahl,项目名称:godot,代码行数:7,代码来源:bitmap_loader_pbm.cpp

示例9: de

Vector<Vector3> ConcavePolygonShape::_gen_debug_mesh_lines() {

	Set<DrawEdge> edges;

	PoolVector<Vector3> data = get_faces();
	int datalen = data.size();
	ERR_FAIL_COND_V((datalen % 3) != 0, Vector<Vector3>());

	PoolVector<Vector3>::Read r = data.read();

	for (int i = 0; i < datalen; i += 3) {

		for (int j = 0; j < 3; j++) {

			DrawEdge de(r[i + j], r[i + ((j + 1) % 3)]);
			edges.insert(de);
		}
	}

	Vector<Vector3> points;
	points.resize(edges.size() * 2);
	int idx = 0;
	for (Set<DrawEdge>::Element *E = edges.front(); E; E = E->next()) {

		points.write[idx + 0] = E->get().a;
		points.write[idx + 1] = E->get().b;
		idx += 2;
	}

	return points;
}
开发者ID:93i,项目名称:godot,代码行数:31,代码来源:concave_polygon_shape.cpp

示例10: _update

/**
  PrimitiveMesh
*/
void PrimitiveMesh::_update() const {

	Array arr;
	arr.resize(VS::ARRAY_MAX);
	_create_mesh_array(arr);

	PoolVector<Vector3> points = arr[VS::ARRAY_VERTEX];

	aabb = AABB();

	int pc = points.size();
	ERR_FAIL_COND(pc == 0);
	{

		PoolVector<Vector3>::Read r = points.read();
		for (int i = 0; i < pc; i++) {
			if (i == 0)
				aabb.position = r[i];
			else
				aabb.expand_to(r[i]);
		}
	}

	// in with the new
	VisualServer::get_singleton()->mesh_clear(mesh);
	VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh, (VisualServer::PrimitiveType)primitive_type, arr);
	VisualServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid());

	pending_request = false;

	_clear_triangle_mesh();
}
开发者ID:brakhane,项目名称:godot,代码行数:35,代码来源:primitive_meshes.cpp

示例11: img

Ref<Texture> EditorPackedScenePreviewPlugin::_gen_from_imd(Ref<ResourceImportMetadata> p_imd) {

	if (p_imd.is_null()) {
		return Ref<Texture>();
	}

	if (!p_imd->has_option("thumbnail"))
		return Ref<Texture>();

	Variant tn = p_imd->get_option("thumbnail");
	//print_line(Variant::get_type_name(tn.get_type()));
	PoolVector<uint8_t> thumbnail = tn;

	int len = thumbnail.size();
	if (len==0)
		return Ref<Texture>();


	PoolVector<uint8_t>::Read r = thumbnail.read();

	Image img(r.ptr(),len);
	if (img.empty())
		return Ref<Texture>();

	Ref<ImageTexture> ptex = Ref<ImageTexture>( memnew( ImageTexture ));
	ptex->create_from_image(img,0);
	return ptex;

}
开发者ID:Alex-doc,项目名称:godot,代码行数:29,代码来源:editor_preview_plugins.cpp

示例12: _put_data

Error StreamPeer::_put_data(const PoolVector<uint8_t> &p_data) {

	int len = p_data.size();
	if (len == 0)
		return OK;
	PoolVector<uint8_t>::Read r = p_data.read();
	return put_data(&r[0], len);
}
开发者ID:Bonfi96,项目名称:godot,代码行数:8,代码来源:stream_peer.cpp

示例13: _load_mem_png

static Ref<Image> _lossless_unpack_png(const PoolVector<uint8_t> &p_data) {

	int len = p_data.size();
	ERR_FAIL_COND_V(len < 4, Ref<Image>());
	PoolVector<uint8_t>::Read r = p_data.read();
	ERR_FAIL_COND_V(r[0] != 'P' || r[1] != 'N' || r[2] != 'G' || r[3] != ' ', Ref<Image>());
	return _load_mem_png(&r[4], len - 4);
}
开发者ID:ISylvox,项目名称:godot,代码行数:8,代码来源:image_loader_png.cpp

示例14: request_raw

Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body) {

	Error err = prepare_request(p_method, p_url, p_headers);
	if (err != OK)
		return err;
	PoolByteArray::Read read = p_body.read();
	godot_xhr_send_data(xhr_id, read.ptr(), p_body.size());
	return OK;
}
开发者ID:KelinciFX,项目名称:godot,代码行数:9,代码来源:http_client_javascript.cpp

示例15: put_packet_buffer

Error PacketPeer::put_packet_buffer(const PoolVector<uint8_t> &p_buffer) {

	int len = p_buffer.size();
	if (len == 0)
		return OK;

	PoolVector<uint8_t>::Read r = p_buffer.read();
	return put_packet(&r[0], len);
}
开发者ID:MattUV,项目名称:godot,代码行数:9,代码来源:packet_peer.cpp


注:本文中的PoolVector::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。