void initPortal(portal_s* p) { if(!p)return; // p->position = vect3Df(); p->target = NULL; updatePortalOrientation(p, vect3Df(0.0f, 0.0f, 1.0f), vect3Df(-1.0f, 0.0f, 0.0f)); p->color = vect3Df(1.0f, 1.0f, 1.0f); p->open = false; p->draw = false; }
void shootPlayerGun(player_s* p, room_s* r, portal_s* portal) { if(!p)return; if(p->gunInstance.currentAnim == PORTALGUN_SHOOT)return; md2InstanceChangeAnimation(&p->gunInstance, PORTALGUN_IDLE, false); md2InstanceChangeAnimation(&p->gunInstance, PORTALGUN_SHOOT, true); vect3Df_s position; rectangle_s* rec = collideLineMapClosest(r, NULL, p->camera.position, vect3Df(-p->camera.orientation[2][0], -p->camera.orientation[2][1], -p->camera.orientation[2][2]), 1000.0f, &position, NULL); if(rec && rec->portalable) { portal_s oldPortal = *portal; vect3Df_s normal = rec->normal; vect3Df_s plane0 = vect3Df(p->camera.orientation[0][0], p->camera.orientation[0][1], p->camera.orientation[0][2]); plane0 = vnormf(vsubf(plane0, vmulf(normal, vdotf(normal, plane0)))); position = vaddf(position, vmulf(normal, -0.05f)); portal->position = position; updatePortalOrientation(portal, plane0, normal); isPortalOnWall(r, portal, true); portal->draw = true; portal->open = true; if(isPortalOnWall(r, portal, false)) { ejectPortalOBBs(portal); ejectPortalOBBs(portal->target); }else{ *portal = oldPortal; } } }