MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / MakeBulletObject

Method MakeBulletObject

Source/Objects/itemobject.cpp:211–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211void ItemObject::MakeBulletObject() {
212 if (!bullet_object_ && scenegraph_) {
213 bullet_object_ = scenegraph_->bullet_world_->CreateConvexModel(
214 vec3(0.0f),
215 ofc_->model_name,
216 &display_phys_offset_);
217 bullet_object_->keep_history = true;
218 Model& model = Models::Instance()->GetModel(model_id_);
219 phys_offset_ = model.old_center + display_phys_offset_;
220 bullet_object_->owner_object = this;
221 vec3 new_pos = GetTranslation() +
222 GetRotation() * display_phys_offset_;
223 bullet_object_->SetTransform(new_pos, Mat4FromQuaternion(GetRotation()), vec4(1.0f));
224 bullet_object_->SetMass(item_ref_->GetMass());
225 bullet_object_->body->setCcdMotionThreshold(0.000001f);
226 bullet_object_->body->setCcdSweptSphereRadius(0.05f);
227
228 abstract_bullet_object_ = scenegraph_->abstract_bullet_world_->CreateConvexModel(
229 vec3(0.0f),
230 ofc_->model_name,
231 &display_phys_offset_,
232 BW_ABSTRACT_ITEM);
233 abstract_bullet_object_->body->setCollisionFlags(abstract_bullet_object_->body->getCollisionFlags() |
234 btCollisionObject::CF_NO_CONTACT_RESPONSE);
235 abstract_bullet_object_->keep_history = true;
236 abstract_bullet_object_->owner_object = this;
237 abstract_bullet_object_->SetTransform(new_pos, Mat4FromQuaternion(GetRotation()), vec4(1.0f));
238 abstract_bullet_object_->body->setInterpolationWorldTransform(abstract_bullet_object_->body->getWorldTransform());
239 abstract_bullet_object_->Activate();
240 }
241}
242
243bool ItemObject::Initialize() {
244 update_list_entry = scenegraph_->LinkUpdateObject(this);

Callers

nothing calls this directly

Calls 11

GetTranslationFunction · 0.85
GetRotationFunction · 0.85
Mat4FromQuaternionFunction · 0.85
CreateConvexModelMethod · 0.80
SetMassMethod · 0.80
vec3Class · 0.50
vec4Class · 0.50
GetModelMethod · 0.45
SetTransformMethod · 0.45
GetMassMethod · 0.45
ActivateMethod · 0.45

Tested by

no test coverage detected