| 1085 | } |
| 1086 | |
| 1087 | void ItemObject::CheckThrownCollisionLine(int line_id, const mat4& cur_transform, const mat4& transform) { |
| 1088 | vec3 point, normal, start, end; |
| 1089 | start = transform * item_ref_->GetLineStart(line_id); |
| 1090 | end = transform * item_ref_->GetLineEnd(line_id); |
| 1091 | int bone = -1; |
| 1092 | int char_id = scenegraph_->CheckRayCollisionCharacters(start, |
| 1093 | end, |
| 1094 | &point, |
| 1095 | &normal, |
| 1096 | &bone); |
| 1097 | if (char_id == last_held_char_id_) { // && active_time < 0.1f){ |
| 1098 | return; |
| 1099 | } |
| 1100 | vec4 color(1.0f); |
| 1101 | if (item_ref_->GetLineMaterial(line_id) == "wood") { |
| 1102 | color = vec4(105 / 255.0f, 77 / 255.0f, 50 / 255.0f, 1.0f); |
| 1103 | } |
| 1104 | if (char_id != -1 && !IsHeld() && !IsStuckInCharacter()) { |
| 1105 | if (_debug_draw_collision) { |
| 1106 | DebugDraw::Instance()->AddWireSphere(point, 0.2f, color, _fade); |
| 1107 | } |
| 1108 | Object* obj = scenegraph_->GetObjectFromID(char_id); |
| 1109 | MovementObject* mo = (MovementObject*)obj; |
| 1110 | |
| 1111 | if (thrown_ != kSafe) { |
| 1112 | int accept_hit = 1; |
| 1113 | { |
| 1114 | accept_hit = mo->AboutToBeHitByItem(GetID()); |
| 1115 | } |
| 1116 | if (accept_hit == 1) { |
| 1117 | bool will_cut = false; |
| 1118 | int vert = GetClosestVert(point + normalize(GetLinearVelocity())); |
| 1119 | float sharpness = GetVertSharpness(vert); |
| 1120 | if (sharpness > 0.3f && item_ref_->GetLineMaterial(line_id) == "metal") { |
| 1121 | will_cut = true; |
| 1122 | } |
| 1123 | bool will_stick = false; |
| 1124 | if (will_cut) { |
| 1125 | mo->rigged_object()->Stab(point, normalize(end - start), _heavy, 0); |
| 1126 | AddBloodDecal(cur_transform * invert(transform) * point, normalize(end - start), 0.2f); |
| 1127 | |
| 1128 | if (item_ref_->GetLabel() == "spear") { |
| 1129 | will_stick = true; |
| 1130 | } |
| 1131 | if (fabs(dot(normalize(end - start), normal)) > 0.4f) { |
| 1132 | will_stick = true; |
| 1133 | } |
| 1134 | if (will_stick) { |
| 1135 | mat4 stick_transform = transform; |
| 1136 | stick_transform.AddTranslation(point - end); |
| 1137 | stick_transform.AddTranslation(transform.GetRotatedvec3(phys_offset_ * -1.0f)); |
| 1138 | float stick_depth = 0.4f; |
| 1139 | stick_transform.AddTranslation(normalize(end - start) * stick_depth); |
| 1140 | |
| 1141 | if (bone != -1) { |
| 1142 | // stick_transform = mo->rigged_object()->skeleton_.physics_bones[bone].bullet_object->GetTransform(); |
| 1143 | mo->rigged_object()->StickItem(GetID(), start, end, stick_transform); |
| 1144 | } |
nothing calls this directly
no test coverage detected