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


C++ const_entity_handle::get_id方法代码示例

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


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

示例1: destruct

void physics_system::destruct(const const_entity_handle handle) {
	if (is_constructed_rigid_body(handle)) {
		auto& cache = get_rigid_body_cache(handle);
		
		for (const auto& colliders_cache_id : cache.correspondent_colliders_caches)
			colliders_caches[colliders_cache_id] = colliders_cache();

		b2world->DestroyBody(cache.body);

		cache = rigid_body_cache();
	}
	
	if (is_constructed_colliders(handle)) {
		const auto this_cache_id = handle.get_id().pool.indirection_index;
		auto& cache = colliders_caches[this_cache_id];

		ensure(cache.correspondent_rigid_body_cache != -1);

		auto& owner_body_cache = rigid_body_caches[cache.correspondent_rigid_body_cache];

		for (const auto& f_per_c : cache.fixtures_per_collider)
			for (const auto f : f_per_c)
				owner_body_cache.body->DestroyFixture(f);

		remove_element(owner_body_cache.correspondent_colliders_caches, this_cache_id);
		cache = colliders_cache();
	}
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: interpolation

std::optional<transformr> interpolation_system::find_interpolated(const const_entity_handle handle) const {
	const auto id = handle.get_id();

	auto result = [&]() -> std::optional<transformr> {
		if (enabled) {
			if (const auto cache = mapped_or_nullptr(per_entity_cache, id)) {
				return cache->interpolated_transform;
			}
		}

		return handle.find_logic_transform();
	}();

	/*
		Here, we integerize the transform of the viewed entity, (and later possibly of the vehicle that it drives)
		so that the rendered player does not shake when exactly followed by the camera,
		which is also integerized for pixel-perfect rendering.

		Ideally we shouldn't do it here because it introduces more state, but that's about the simplest solution
		that doesn't make a mess out of rendering scripts for this special case.	

		Additionally, if someone does not use interpolation (there should be no need to disable it, really)
		they will still suffer from the problem of shaky controlled player. We don't have time for now to handle it better.
	*/

	if (id == id_to_integerize) {
		if (result) {
			result->pos.discard_fract();
		}
	}

	return result;
}
开发者ID:TeamHypersomnia,项目名称:Augmentations,代码行数:33,代码来源:interpolation_system.cpp

示例3: acquire_potential_misprediction

simulation_receiver::misprediction_candidate_entry simulation_receiver::acquire_potential_misprediction(const const_entity_handle& e) const {
	misprediction_candidate_entry candidate;
	
	if(e.has_logic_transform())
		candidate.transform = e.logic_transform();

	candidate.id = e.get_id();

	return candidate;
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例4: set_updated_interpolated_transform

void interpolation_system::set_updated_interpolated_transform(
	const const_entity_handle subject,
	const transformr updated_value
) {
	auto& cache = per_entity_cache[subject];
	const auto& info = subject.get<components::interpolation>();
	
	cache.recorded_place_of_birth = info.place_of_birth;
	cache.interpolated_transform = updated_value;
	cache.recorded_version = subject.get_id().raw.version;
}
开发者ID:TeamHypersomnia,项目名称:Augmentations,代码行数:11,代码来源:interpolation_system.cpp

示例5: make_pair

std::pair<size_t, size_t> physics_system::map_fixture_pointer_to_indices(const b2Fixture* const f, const const_entity_handle& handle) {
	const auto this_cache_id = handle.get_id().pool.indirection_index;
	const auto& cache = colliders_caches[this_cache_id];

	for (size_t collider_index = 0; collider_index < cache.fixtures_per_collider.size(); ++collider_index) {
		for (size_t convex_index = 0; convex_index < cache.fixtures_per_collider[collider_index].size(); ++convex_index) {
			if (cache.fixtures_per_collider[collider_index][convex_index] == f) {
				return std::make_pair(collider_index, convex_index);
			}
		}
	}

	ensure(false);
	return{};
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例6: construct

void physics_system::construct(const const_entity_handle handle) {
	//ensure(!is_constructed_rigid_body(handle));
	if (is_constructed_rigid_body(handle))
		return;

	fixtures_construct(handle);

	if (handle.has<components::physics>()) {
		const auto& physics = handle.get<components::physics>();
		const auto& fixture_entities = physics.get_fixture_entities();

		if (physics.is_activated() && fixture_entities.size() > 0) {
			const auto& physics_data = physics.get_data();
			auto& cache = get_rigid_body_cache(handle);

			b2BodyDef def;

			switch (physics_data.body_type) {
			case components::physics::type::DYNAMIC: def.type = b2BodyType::b2_dynamicBody; break;
			case components::physics::type::STATIC: def.type = b2BodyType::b2_staticBody; break;
			case components::physics::type::KINEMATIC: def.type = b2BodyType::b2_kinematicBody; break;
			default:ensure(false) break;
			}

			def.userData = handle.get_id();
			def.bullet = physics_data.bullet;
			def.transform = physics_data.transform;
			def.sweep = physics_data.sweep;
			def.angularDamping = physics_data.angular_damping;
			def.linearDamping = physics_data.linear_damping;
			def.fixedRotation = physics_data.fixed_rotation;
			def.gravityScale = physics_data.gravity_scale;
			def.active = true;
			def.linearVelocity = physics_data.velocity;
			def.angularVelocity = physics_data.angular_velocity;

			cache.body = b2world->CreateBody(&def);
			cache.body->SetAngledDampingEnabled(physics_data.angled_damping);
			
			/* notice that all fixtures must be unconstructed at this moment since we assert that the rigid body itself is not */
			for (const auto& f : fixture_entities)
				fixtures_construct(f);
		}
	}
}
开发者ID:,项目名称:,代码行数:45,代码来源:

示例7: fixtures_construct

void physics_system::fixtures_construct(const const_entity_handle handle) {
	//ensure(!is_constructed_colliders(handle));
	if (is_constructed_colliders(handle))
		return;

	if (handle.has<components::fixtures>()) {
		const auto colliders = handle.get<components::fixtures>();

		if (colliders.is_activated() && is_constructed_rigid_body(colliders.get_owner_body())) {
			const auto& colliders_data = colliders.get_data();
			auto& cache = get_colliders_cache(handle);

			const auto owner_body_entity = colliders.get_owner_body();
			ensure(owner_body_entity.alive());
			auto& owner_cache = get_rigid_body_cache(owner_body_entity);

			const auto this_cache_id = handle.get_id().pool.indirection_index;
			const auto owner_cache_id = owner_body_entity.get_id().pool.indirection_index;

			owner_cache.correspondent_colliders_caches.push_back(this_cache_id);
			cache.correspondent_rigid_body_cache = owner_cache_id;

			for (size_t ci = 0; ci < colliders_data.colliders.size(); ++ci) {
				const auto& c = colliders_data.colliders[ci];

				b2PolygonShape shape;

				b2FixtureDef fixdef;
				fixdef.density = c.density;
				fixdef.friction = c.friction;
				fixdef.isSensor = c.sensor;
				fixdef.filter = c.filter;
				fixdef.restitution = c.restitution;
				fixdef.shape = &shape;
				fixdef.userData = handle.get_id();

				auto transformed_shape = c.shape;
				transformed_shape.offset_vertices(colliders.get_total_offset());

				std::vector<b2Fixture*> partitioned_collider;

				for (const auto convex : transformed_shape.convex_polys) {
					std::vector<b2Vec2> b2verts(convex.vertices.begin(), convex.vertices.end());

					for (auto& v : b2verts)
						v *= PIXELS_TO_METERSf;

					shape.Set(b2verts.data(), b2verts.size());

					b2Fixture* const new_fix = owner_cache.body->CreateFixture(&fixdef);
					
					ensure(static_cast<short>(ci) < std::numeric_limits<short>::max());
					new_fix->collider_index = static_cast<short>(ci);

					partitioned_collider.push_back(new_fix);
				}

				cache.fixtures_per_collider.push_back(partitioned_collider);
			}
		}
	}
}
开发者ID:,项目名称:,代码行数:62,代码来源:


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