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


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

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


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

示例1: memnew

Ref<Shape> Mesh::create_trimesh_shape() const {

	PoolVector<Face3> faces = get_faces();
	if (faces.size() == 0)
		return Ref<Shape>();

	PoolVector<Vector3> face_points;
	face_points.resize(faces.size() * 3);

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

		Face3 f = faces.get(i / 3);
		face_points.set(i, f.vertex[i % 3]);
	}

	Ref<ConcavePolygonShape> shape = memnew(ConcavePolygonShape);
	shape->set_faces(face_points);
	return shape;
}
开发者ID:luchete80,项目名称:GodotGUI,代码行数:19,代码来源:mesh.cpp

示例2: fill_bits

static void fill_bits(const BitMap *p_src, Ref<BitMap> &p_map, const Point2i &p_pos, const Rect2i &rect) {

	// Using a custom stack to work iteratively to avoid stack overflow on big bitmaps
	PoolVector<FillBitsStackEntry> stack;
	// Tracking size since we won't be shrinking the stack vector
	int stack_size = 0;

	Point2i pos = p_pos;
	int next_i = 0;
	int next_j = 0;

	bool reenter = true;
	bool popped = false;
	do {
		if (reenter) {
			next_i = pos.x - 1;
			next_j = pos.y - 1;
			reenter = false;
		}

		for (int i = next_i; i <= pos.x + 1; i++) {
			for (int j = next_j; j <= pos.y + 1; j++) {
				if (popped) {
					// The next loop over j must start normally
					next_j = pos.y;
					popped = false;
					// Skip because an iteration was already executed with current counter values
					continue;
				}

				if (i < rect.position.x || i >= rect.position.x + rect.size.x)
					continue;
				if (j < rect.position.y || j >= rect.position.y + rect.size.y)
					continue;

				if (p_map->get_bit(Vector2(i, j)))
					continue;

				else if (p_src->get_bit(Vector2(i, j))) {
					p_map->set_bit(Vector2(i, j), true);

					FillBitsStackEntry se = { pos, i, j };
					stack.resize(MAX(stack_size + 1, stack.size()));
					stack.set(stack_size, se);
					stack_size++;

					pos = Point2i(i, j);
					reenter = true;
					break;
				}
			}
			if (reenter) {
				break;
			}
		}
		if (!reenter) {
			if (stack_size) {
				FillBitsStackEntry se = stack.get(stack_size - 1);
				stack_size--;
				pos = se.pos;
				next_i = se.i;
				next_j = se.j;
				popped = true;
			}
		}
	} while (reenter || popped);

	print_verbose("BitMap: Max stack size: " + itos(stack.size()));
}
开发者ID:ialex32x,项目名称:godot,代码行数:69,代码来源:bit_mask.cpp

示例3: encode_variant

Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {

	uint8_t *buf = r_buffer;

	r_len = 0;

	uint32_t flags = 0;

	switch (p_variant.get_type()) {

		case Variant::INT: {
			int64_t val = p_variant;
			if (val > 0x7FFFFFFF || val < -0x80000000) {
				flags |= ENCODE_FLAG_64;
			}
		} break;
		case Variant::REAL: {

			double d = p_variant;
			float f = d;
			if (double(f) != d) {
				flags |= ENCODE_FLAG_64; //always encode real as double
			}
		} break;
	}

	if (buf) {
		encode_uint32(p_variant.get_type() | flags, buf);
		buf += 4;
	}
	r_len += 4;

	switch (p_variant.get_type()) {

		case Variant::NIL: {

			//nothing to do
		} break;
		case Variant::BOOL: {

			if (buf) {
				encode_uint32(p_variant.operator bool(), buf);
			}

			r_len += 4;

		} break;
		case Variant::INT: {

			int64_t val = p_variant;
			if (val > 0x7FFFFFFF || val < -0x80000000) {
				//64 bits
				if (buf) {
					encode_uint64(val, buf);
				}

				r_len += 8;
			} else {
				if (buf) {
					encode_uint32(int32_t(val), buf);
				}

				r_len += 4;
			}
		} break;
		case Variant::REAL: {

			double d = p_variant;
			float f = d;
			if (double(f) != d) {
				if (buf) {
					encode_double(p_variant.operator double(), buf);
				}

				r_len += 8;

			} else {

				if (buf) {
					encode_float(p_variant.operator float(), buf);
				}

				r_len += 4;
			}

		} break;
		case Variant::NODE_PATH: {

			NodePath np = p_variant;
			if (buf) {
				encode_uint32(uint32_t(np.get_name_count()) | 0x80000000, buf); //for compatibility with the old format
				encode_uint32(np.get_subname_count(), buf + 4);
				uint32_t flags = 0;
				if (np.is_absolute())
					flags |= 1;
				if (np.get_property() != StringName())
					flags |= 2;

				encode_uint32(flags, buf + 8);

//.........这里部分代码省略.........
开发者ID:GuiltyPixel,项目名称:godot,代码行数:101,代码来源:marshalls.cpp


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