| 114 | } |
| 115 | |
| 116 | void ItemObject::Collided(const vec3& pos, float impulse, const CollideInfo& collide_info, BulletObject* object) { |
| 117 | if (stuck_in_environment_) { |
| 118 | return; |
| 119 | } |
| 120 | if (thrown_ == kThrown || thrown_ == kThrownStraight) { |
| 121 | thrown_ = kBounced; |
| 122 | } |
| 123 | if (scenegraph_->GetMaterialSharpPenetration(pos, this) > 0.0f && !IsConstrained()) { |
| 124 | int vert = GetClosestVert(pos); |
| 125 | float sharpness = GetVertSharpness(vert); |
| 126 | vec3 local_pos = GetVertPos(vert) - display_phys_offset_; |
| 127 | // vec3 local_vel = old_lin_vel_ + cross(old_ang_vel_, local_pos); |
| 128 | vec3 world_vert = bullet_object_->GetTransform() * local_pos; |
| 129 | vec3 vert_dir = normalize(world_vert - bullet_object_->GetPosition()); |
| 130 | // DebugDraw::Instance()->AddLine(pos, pos+collide_info.normal, vec4(0.0f,1.0f,0.5f,1.0f), _persistent); |
| 131 | // DebugDraw::Instance()->AddLine(pos, pos-collide_info.normal, vec4(1.0f,0.0f,0.0f,1.0f), _persistent); |
| 132 | if (sharpness > 0.3f && dot(vert_dir, normalize(old_lin_vel_)) > 0.7f && |
| 133 | dot(vert_dir, collide_info.normal) < -0.5f) { |
| 134 | StickingCollisionOccured(pos, vert, collide_info); |
| 135 | PlayImpactSound(pos, collide_info.normal, bullet_object_->GetMass()); |
| 136 | return; |
| 137 | } |
| 138 | } |
| 139 | if (!collide_info.true_impact) { |
| 140 | return; |
| 141 | } |
| 142 | if (length_squared(object->GetLinearVelocity()) < 0.1f) { |
| 143 | return; |
| 144 | } |
| 145 | if (impact_sound_delay_ <= 0.0f && impulse > 0.1f) { |
| 146 | PlayImpactSound(pos, collide_info.normal, impulse); |
| 147 | } |
| 148 | const MaterialParticle* mp = scenegraph_->GetMaterialParticle("skid", pos); |
| 149 | if (!mp || mp->particle_path.empty()) { |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | vec3 particle_pos = pos; |
| 154 | vec3 vel = vec3(0.0f, 1.0f, 0.0f); |
| 155 | vec3 tint = scenegraph_->GetColorAtPoint(pos); |
| 156 | scenegraph_->particle_system->MakeParticle( |
| 157 | scenegraph_, mp->particle_path, particle_pos, vel, tint); |
| 158 | } |
| 159 | |
| 160 | vec3 ItemObject::GetLinearVelocity() { |
| 161 | return bullet_object_->GetLinearVelocity(); |
nothing calls this directly
no test coverage detected