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


C++ DVector::push_back方法代码示例

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


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

示例1: getHashesAndData

bool D_bjmak::getHashesAndData(int fd, DVector& dataBuffer, DVector& hashBuffer, int blockCount){
    
    string hash;
    hash.reserve(26);
    for(int i = 0; i < blockCount; ++i){
        char buf[bsize_];
        int l = read(fd, buf, bsize_);
        //cout << " read " << l << " i = " << i << "blockCount = " << blockCount << endl;
        
        if (l == -1){
            cout << " read errror " << strerror(errno) << endl;
            return false;
        }
        
        DVector hashstr;
        hash = Hash::sha1(buf, l);
        hashstr.push_back(hash.data(), hash.size());
        hashstr.push_back(int64_to_byte(Hash::crc32(buf, l), 4));
        hashstr.push_back(int64_to_byte(l, 2));
        hashBuffer.push_back(hashstr);
        dataBuffer.push_back(buf, l);
    }
    
    return true;
}
开发者ID:thebatua,项目名称:debus,代码行数:25,代码来源:DTPAgentsCommand.cpp

示例2:

DVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {

	DVector<Plane> planes;

	Vector3 axis;
	axis[p_axis] = 1.0;

	Vector3 axis_neg;
	axis_neg[(p_axis + 1) % 3] = 1.0;
	axis_neg[(p_axis + 2) % 3] = 1.0;
	axis_neg[p_axis] = -1.0;

	for (int i = 0; i < p_sides; i++) {

		Vector3 normal;
		normal[(p_axis + 1) % 3] = Math::cos(i * (2.0 * Math_PI) / p_sides);
		normal[(p_axis + 2) % 3] = Math::sin(i * (2.0 * Math_PI) / p_sides);

		planes.push_back(Plane(normal, p_radius));

		for (int j = 1; j <= p_lats; j++) {

			Vector3 angle = normal.linear_interpolate(axis, j / (float)p_lats).normalized();
			Vector3 pos = axis * p_height * 0.5 + angle * p_radius;
			planes.push_back(Plane(pos, angle));
			planes.push_back(Plane(pos * axis_neg, angle * axis_neg));
		}
	}

	return planes;
}
开发者ID:allkhor,项目名称:godot,代码行数:31,代码来源:geometry.cpp

示例3: memnew

Ref<Mesh> SceneTree::get_debug_contact_mesh() {

	if (debug_contact_mesh.is_valid())
		return debug_contact_mesh;

	debug_contact_mesh = Ref<Mesh>( memnew( Mesh ) );

	Ref<FixedMaterial> mat = memnew( FixedMaterial );
	mat->set_flag(Material::FLAG_UNSHADED,true);
	mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
	mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
	mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());

	Vector3 diamond[6]={
		Vector3(-1, 0, 0),
		Vector3( 1, 0, 0),
		Vector3( 0, -1, 0),
		Vector3( 0, 1, 0),
		Vector3( 0, 0, -1),
		Vector3( 0, 0, 1)
	};

	int diamond_faces[8*3]={
		0,2,4,
		0,3,4,
		1,2,4,
		1,3,4,
		0,2,5,
		0,3,5,
		1,2,5,
		1,3,5,
	};

	DVector<int> indices;
	for(int i=0;i<8*3;i++)
		indices.push_back(diamond_faces[i]);

	DVector<Vector3> vertices;
	for(int i=0;i<6;i++)
		vertices.push_back(diamond[i]*0.1);

	Array arr;
	arr.resize(Mesh::ARRAY_MAX);
	arr[Mesh::ARRAY_VERTEX]=vertices;
	arr[Mesh::ARRAY_INDEX]=indices;


	debug_contact_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);
	debug_contact_mesh->surface_set_material(0,mat);

	return debug_contact_mesh;

}
开发者ID:hellaguy130,项目名称:godot,代码行数:53,代码来源:scene_main_loop.cpp

示例4:

DVector<int> Font::_get_kernings() const {

	DVector<int> kernings;

	for(Map<KerningPairKey,int>::Element *E=kerning_map.front();E;E=E->next()) {

		kernings.push_back(E->key().A);
		kernings.push_back(E->key().B);
		kernings.push_back(E->get());
	}

	return kernings;
}
开发者ID:ShadowKyogre,项目名称:godot,代码行数:13,代码来源:font.cpp

示例5: _update_areas_display

void GridMapEditor::_update_areas_display() {


	_clear_areas();
	List<int> areas;
	node->get_area_list(&areas);

	Transform global_xf = node->get_global_transform();

	for(List<int>::Element *E=areas.front();E;E=E->next()) {

		int area = E->get();
		Color color;
		if (node->area_is_exterior_portal(area))
			color=Color(1,1,1,0.2);
		else
			color.set_hsv(Math::fmod(area*0.37,1),Math::fmod(area*0.75,1),1.0,0.2);
		RID material = VisualServer::get_singleton()->fixed_material_create();
		VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_DIFFUSE,color );
		VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_EMISSION,0.5 );
		VisualServer::get_singleton()->fixed_material_set_flag( material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );


		RID mesh = VisualServer::get_singleton()->mesh_create();

		DVector<Plane> planes;
		for(int i=0;i<3;i++) {

			Vector3 axis;
			axis[i]=1.0;
			planes.push_back(Plane(axis,1));
			planes.push_back(Plane(-axis,0));
		}

		VisualServer::get_singleton()->mesh_add_surface_from_planes(mesh,planes);
		VisualServer::get_singleton()->mesh_surface_set_material(mesh,0,material,true);

		AreaDisplay ad;
		ad.mesh=mesh;
		ad.instance = VisualServer::get_singleton()->instance_create2(mesh,node->get_world()->get_scenario());
		Transform xform;
		AABB aabb = node->area_get_bounds(area);
		xform.origin=aabb.pos * node->get_cell_size();
		xform.basis.scale(aabb.size * node->get_cell_size());
		VisualServer::get_singleton()->instance_set_transform(ad.instance,global_xf * xform);
		this->areas.push_back(ad);

	}

}
开发者ID:MonochromeBears,项目名称:godot,代码行数:50,代码来源:grid_map_editor_plugin.cpp

示例6:

DVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {

	if (!(p_usage_flags&FACES_ENCLOSING))
		return DVector<Face3>();

	Vector<Point2> shape = get_shape();
	if (shape.size()==0)
		return DVector<Face3>();
		
	Vector2 center;
	for (int i=0;i<shape.size();i++) {
	
		center+=shape[i];
		
	}
	
	DVector<Face3> ret;
	center/=shape.size();

	for (int i=0;i<shape.size();i++) {

		int n=(i+1)%shape.size();
		
		Face3 f;
		f.vertex[0]=Vector3( center.x, center.y, 0 );
		f.vertex[1]=Vector3( shape[i].x, shape[i].y, 0 );
		f.vertex[2]=Vector3( shape[n].x, shape[n].y, 0 );
		ret.push_back(f);
	}
	
	return ret;
}
开发者ID:0871087123,项目名称:godot,代码行数:32,代码来源:portal.cpp

示例7: getDataBufferFromReply

DVector D_bjmak::getDataBufferFromReply(DVector& reply, DVector& hashBuffer, DVector& dataBuffer){
    int dataPos = 0;
    int blockCount = reply.size();
    char* hashBufferPtr = hashBuffer.data();
    char* dataBufferPtr = dataBuffer.data();
    DVector res;
    res.reserve(blockCount*bsize_);
    
    for(int i = 0; i < blockCount; ++i){
        int dataBlockSize = byte_to_int64((hashBufferPtr+i*(D_LENGTH_OF_HASH+2)+D_LENGTH_OF_HASH), 2);
        
        if (reply[i] == 1){
            //cout << " 1 " << dataBlockSize << endl;
            res.push_back(dataBufferPtr+dataPos, dataBlockSize);
        }else
            //cout << " - " << (int)reply[i] << "  " << dataBuffer.size() << " " << hashBuffer.size()<< " " << dataBlockSize << endl;
            
        
        dataPos += dataBlockSize;
    }
    
    //cout << endl;
    return move(res);
    
}
开发者ID:thebatua,项目名称:debus,代码行数:25,代码来源:DTPAgentsCommand.cpp

示例8: _action_pressed

void FileDialog::_action_pressed() {
	
	if (mode==MODE_OPEN_FILES) {

		TreeItem *ti=tree->get_next_selected(NULL);
		String fbase=dir_access->get_current_dir();

		DVector<String> files;
		while(ti) {

			files.push_back( fbase.plus_file(ti->get_text(0)) );
			ti=tree->get_next_selected(ti);
		}

		if (files.size()) {
			emit_signal("files_selected",files);
			hide();
		}

		return;
	}

	String f=dir_access->get_current_dir().plus_file(file->get_text());
	                   
	if (mode==MODE_OPEN_FILE && dir_access->file_exists(f)) {
		emit_signal("file_selected",f);
		hide();
	}

	if (mode==MODE_OPEN_DIR) {


		String path=dir_access->get_current_dir();
		/*if (tree->get_selected()) {
			Dictionary d = tree->get_selected()->get_metadata(0);
			if (d["dir"]) {
				path=path+"/"+String(d["name"]);
			}
		}*/
		path=path.replace("\\","/");
		emit_signal("dir_selected",path);
		hide();
	}

	if (mode==MODE_SAVE_FILE) {
		
		if (dir_access->file_exists(f)) {
			confirm_save->set_text("File Exists, Overwrite?");
			confirm_save->popup_centered(Size2(200,80));
		} else {
			
			emit_signal("file_selected",f);
			hide();
		}
	}
}
开发者ID:0871087123,项目名称:godot,代码行数:56,代码来源:file_dialog.cpp

示例9:

DVector<String> SceneState::_get_node_groups(int p_idx) const {

	Vector<StringName> groups = get_node_groups(p_idx);
	DVector<String> ret;

	for(int i=0;i<groups.size();i++)
		ret.push_back(groups[i]);

	return ret;
}
开发者ID:zuloloxi,项目名称:godot,代码行数:10,代码来源:packed_scene.cpp

示例10: _get

bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {

	String sname=p_name;

	if (p_name=="morph_target/names") {

		DVector<String> sk;
		for(int i=0;i<morph_targets.size();i++)
			sk.push_back(morph_targets[i]);
		r_ret=sk;
		return true;
	} else if (p_name=="morph_target/mode") {

		r_ret = get_morph_target_mode();
		return true;
	} else if (sname.begins_with("surface_")) {

		int sl=sname.find("/");
		if (sl==-1)
			return false;
		int idx=sname.substr(8,sl-8).to_int()-1;
		String what = sname.get_slice("/",1);
		if (what=="material")
			r_ret=surface_get_material(idx);
		else if (what=="name")
			r_ret=surface_get_name(idx);
		return true;
	} else if (sname=="custom_aabb/custom_aabb") {

		r_ret=custom_aabb;
		return true;

	} else if (!sname.begins_with("surfaces"))
		return false;


	int idx=sname.get_slice("/",1).to_int();
	ERR_FAIL_INDEX_V(idx,surfaces.size(),false);

	Dictionary d;
	d["primitive"]=surface_get_primitive_type(idx);
	d["arrays"]=surface_get_arrays(idx);
	d["morph_arrays"]=surface_get_morph_arrays(idx);
	d["alphasort"]=surface_is_alpha_sorting_enabled(idx);
	Ref<Material> m = surface_get_material(idx);
	if (m.is_valid())
		d["material"]=m;
	String n = surface_get_name(idx);
	if (n!="")
		d["name"]=n;

	r_ret=d;

	return true;
}
开发者ID:NosicLin,项目名称:godot,代码行数:55,代码来源:mesh.cpp

示例11: mesh_add_surface_from_mesh_data

void VisualServer::mesh_add_surface_from_mesh_data( RID p_mesh, const Geometry::MeshData& p_mesh_data) {

#if 1
	DVector<Vector3> vertices;
	DVector<Vector3> normals;
		
	for (int i=0;i<p_mesh_data.faces.size();i++) {
	
		const Geometry::MeshData::Face& f = p_mesh_data.faces[i];
		
		for (int j=2;j<f.indices.size();j++) {
			
#define _ADD_VERTEX(m_idx)\
	vertices.push_back( p_mesh_data.vertices[ f.indices[m_idx] ] );\
	normals.push_back( f.plane.normal );
	
			_ADD_VERTEX( 0 );
			_ADD_VERTEX( j-1 );
			_ADD_VERTEX( j );
		}	
	}
	
	int s = mesh_get_surface_count(p_mesh);
	Array d;
	d.resize(VS::ARRAY_MAX);
	d[ARRAY_VERTEX]=vertices;
	d[ARRAY_NORMAL]=normals;
	mesh_add_surface(p_mesh,PRIMITIVE_TRIANGLES, d);

#else


	DVector<Vector3> vertices;



	for (int i=0;i<p_mesh_data.edges.size();i++) {

		const Geometry::MeshData::Edge& f = p_mesh_data.edges[i];
		vertices.push_back(p_mesh_data.vertices[ f.a]);
		vertices.push_back(p_mesh_data.vertices[ f.b]);
	}

	Array d;
	d.resize(VS::ARRAY_MAX);
	d[ARRAY_VERTEX]=vertices;
	mesh_add_surface(p_mesh,PRIMITIVE_LINES, d);




#endif
	
}
开发者ID:9cat,项目名称:godot,代码行数:54,代码来源:visual_server.cpp

示例12:

DVector<String> _ResourceSaver::get_recognized_extensions(const RES& p_resource) {

    ERR_FAIL_COND_V(p_resource.is_null(),DVector<String>());
    List<String> exts;
    ResourceSaver::get_recognized_extensions(p_resource,&exts);
    DVector<String> ret;
    for(List<String>::Element *E=exts.front(); E; E=E->next()) {

        ret.push_back(E->get());
    }
    return ret;
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例13: MultiplyVectors

DVector* NextCalculator::MultiplyVectors(std::vector<double> & first, std::vector<double> & second) {
	DVector coeffs_tmp;
	DVector *ret;

	if (first.size() < 1) {
		ret = new DVector(second);
		return ret;
	}

	if (second.size() < 1) {
		ret = new DVector(first);
		return ret;
	}

	if (second.size() != 2)
		throw NextException("Second vector's size is not 2.");

	ret = new DVector();

	for (DVector::iterator first_ite = first.begin(); first_ite != first.end(); ++first_ite)
		for (DVector::iterator second_ite = second.begin(); second_ite != second.end(); ++second_ite)
			coeffs_tmp.push_back(*first_ite * *second_ite);

	ret->push_back(coeffs_tmp.data()[0]);

	double tmp = 0;
	for (int i = 1; i < coeffs_tmp.size()-1; i++) {
		tmp += coeffs_tmp.data()[i];

		if (i % 2 == 0) {
			ret->push_back(tmp);
			tmp = 0;
		}
	}

	ret->push_back(coeffs_tmp.data()[coeffs_tmp.size()-1]);

	return ret;
}
开发者ID:massix,项目名称:Sensitive,代码行数:39,代码来源:NextCalculator.cpp

示例14:

DVector<String> VisualServer::_shader_get_param_list(RID p_shader) const {

//remove at some point

	DVector<String> pl;


#if 0
	List<StringName> params;
	shader_get_param_list(p_shader,&params);


	for(List<StringName>::Element *E=params.front();E;E=E->next()) {

		pl.push_back(E->get());
	}
#endif
	return pl;
}
开发者ID:9cat,项目名称:godot,代码行数:19,代码来源:visual_server.cpp

示例15:

DVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start) {

	if (node->get_cell(p_start.x, p_start.y) != TileMap::INVALID_CELL)
		return DVector<Vector2>();

	int id = get_selected_tile();

	if (id == TileMap::INVALID_CELL)
		return DVector<Vector2>();

	Rect2 r = node->get_item_rect();
	r.pos = r.pos/node->get_cell_size();
	r.size = r.size/node->get_cell_size();

	DVector<Vector2> points;

	List<Point2i> queue;
	queue.push_back(p_start);

	while (queue.size()) {

		Point2i n = queue.front()->get();
		queue.pop_front();

		if (!r.has_point(n))
			continue;

		if (node->get_cell(n.x, n.y) == TileMap::INVALID_CELL) {

			node->set_cellv(n, id, flip_h, flip_v, transpose);

			points.push_back(n);

			queue.push_back(n + Point2i(0, 1));
			queue.push_back(n + Point2i(0, -1));
			queue.push_back(n + Point2i(1, 0));
			queue.push_back(n + Point2i(-1, 0));
		}
	}

	return points;
}
开发者ID:baifang,项目名称:godot,代码行数:42,代码来源:tile_map_editor_plugin.cpp


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