diff --git a/OVP/D3D7Client/CSphereMgr.cpp b/OVP/D3D7Client/CSphereMgr.cpp index ec66e6887..2a5b06a65 100644 --- a/OVP/D3D7Client/CSphereMgr.cpp +++ b/OVP/D3D7Client/CSphereMgr.cpp @@ -309,7 +309,7 @@ void CSphereManager::Render (LPDIRECT3DDEVICE7 dev, int level, double bglvl) MATRIX3 rcam = *scn->GetCamera()->GetGRot(); rcam = mul (ecl2gal, rcam); - RenderParam.camdir = _V(rcam.m13, rcam.m23, rcam.m33); + RenderParam.camdir = {rcam.m13, rcam.m23, rcam.m33}; dev->SetRenderState (D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); dev->SetRenderState (D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); @@ -406,7 +406,7 @@ void CSphereManager::ProcessTile (int lvl, int hemisp, int ilat, int nlat, int i static const double rad0 = sqrt(2.0)*PI05; VECTOR3 cnt = TileCentre (hemisp, ilat, nlat, ilng, nlng); double rad = rad0/(double)nlat; - double alpha = acos (dotp (RenderParam.camdir, cnt)); + double alpha = std::acos(dot(RenderParam.camdir, cnt)); double adist = alpha - rad; if (adist > RenderParam.viewap) return; @@ -477,8 +477,8 @@ VECTOR3 CSphereManager::TileCentre (int hemisp, int ilat, int nlat, int ilng, in { double cntlat = PI05 * ((double)ilat+0.5)/(double)nlat, slat = sin(cntlat), clat = cos(cntlat); double cntlng = PI2 * ((double)ilng+0.5)/(double)nlng + PI, slng = sin(cntlng), clng = cos(cntlng); - if (hemisp) return _V(clat*clng, -slat, -clat*slng); - else return _V(clat*clng, slat, clat*slng); + if (hemisp) return {clat*clng, -slat, -clat*slng}; + else return {clat*clng, slat, clat*slng}; } // ======================================================================= diff --git a/OVP/D3D7Client/CloudMgr.cpp b/OVP/D3D7Client/CloudMgr.cpp index f26e2ff7a..047353413 100644 --- a/OVP/D3D7Client/CloudMgr.cpp +++ b/OVP/D3D7Client/CloudMgr.cpp @@ -36,7 +36,7 @@ CloudManager::CloudManager (const D3D7Client *gclient, const vPlanet *vplanet) maxlvl = min (*(int*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL), // global setting *(int*)oapiGetObjectParam (obj, OBJPRM_PLANET_SURFACEMAXLEVEL)); // planet-specific setting maxbaselvl = min (8, maxlvl); - pcdir = _V(1,0,0); + pcdir = {1,0,0}; lightfac = *(double*)gc->GetConfigParam (CFGPRM_SURFACELIGHTBRT); nmask = 0; nhitex = nhispec = 0; diff --git a/OVP/D3D7Client/HazeMgr.cpp b/OVP/D3D7Client/HazeMgr.cpp index b4397292e..fa2b5e542 100644 --- a/OVP/D3D7Client/HazeMgr.cpp +++ b/OVP/D3D7Client/HazeMgr.cpp @@ -36,7 +36,7 @@ HazeManager::HazeManager (const D3D7Client *gclient, const vPlanet *vplanet) dens0 = (float)(min (1.0, atmc->horizonalt/64e3 * *(double*)oapiGetObjectParam (obj, OBJPRM_PLANET_HAZEDENSITY))); } else { - basecol = _V(1,1,1); + basecol = {1,1,1}; hralt = 0.01f; dens0 = 1.0f; } @@ -113,7 +113,7 @@ void HazeManager::Render (LPDIRECT3DDEVICE7 dev, D3DMATRIX &wmat, bool dual) float dens = (float)max (1.0, 1.4 - 0.3/hralt*(cdist-1.0)); // saturate haze colour at low altitudes if (dual) dens *= (float)(0.5 + 0.5/cdist); // scale down intensity at large distances - normalise (rpos); + rpos = unit(rpos); cost = (float)rpos.y, sint = (float)sqrt (1.0-cost*cost); phi = atan2 (rpos.z, rpos.x), cosp = (float)cos(phi), sinp = (float)sin(phi); D3DMATRIX rmat = {cost*cosp, -sint, cost*sinp, 0, @@ -131,8 +131,8 @@ void HazeManager::Render (LPDIRECT3DDEVICE7 dev, D3DMATRIX &wmat, bool dual) oapiGetGlobalPos (obj, &gpos); psun = tmul (grot, -gpos); // sun in planet coords psun = mul (rrmat, psun); // sun in camera-relative horizon coords - VECTOR3 cs = psun-cpos; normalise(cs); // camera->sun - normalise (psun); + VECTOR3 cs = unit(psun - cpos); // camera->sun + psun = unit(psun); float psunx = (float)psun.x, psuny = (float)psun.y, psunz = (float)psun.z; colofs = (dual ? 0.4 : 0.3); @@ -146,10 +146,10 @@ void HazeManager::Render (LPDIRECT3DDEVICE7 dev, D3DMATRIX &wmat, bool dual) dev->SetTextureStageState (0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); for (i = j = 0; i < HORIZON_NSEG; i++) { - VECTOR3 hp = {Vtx[j].x = r1*CosP[i], Vtx[j].y = h1, Vtx[j].z = r1*SinP[i]}; - csun = dotp (hp, psun); - VECTOR3 cp = hp-cpos; normalise(cp); - double colsh = 0.5*(dotp (cp,cs) + 1.0); + VECTOR3 hp{Vtx[j].x = r1*CosP[i], Vtx[j].y = h1, Vtx[j].z = r1*SinP[i]}; + csun = dot(hp, psun); + VECTOR3 cp = unit(hp - cpos); + double colsh = 0.5 * (dot(cp, cs) + 1.0); // compose a colourful sunset double maxred = colofs-0.18*colsh, minred = maxred-0.4; diff --git a/OVP/D3D7Client/Light.cpp b/OVP/D3D7Client/Light.cpp index 185fad74d..e41d6700e 100644 --- a/OVP/D3D7Client/Light.cpp +++ b/OVP/D3D7Client/Light.cpp @@ -22,7 +22,7 @@ D3D7Light::D3D7Light (OBJHANDLE _hObj, LTYPE _ltype, const Scene *scene, DWORD _idx) { hObj = _hObj; - rpos = _V(0,0,0); + rpos = {0,0,0}; ltype = _ltype; scn = scene; idx = _idx; @@ -64,7 +64,7 @@ void D3D7Light::UpdateDirectional () VECTOR3 rpos; oapiGetGlobalPos (hObj, &rpos); rpos -= *scn->GetCamera()->GetGPos(); // object position rel. to camera - rpos /= -length(rpos); // normalise + rpos /= -len(rpos); // normalise D3DVEC(rpos, light.dvDirection); } diff --git a/OVP/D3D7Client/Particle.cpp b/OVP/D3D7Client/Particle.cpp index dd03333f0..1e078cafc 100644 --- a/OVP/D3D7Client/Particle.cpp +++ b/OVP/D3D7Client/Particle.cpp @@ -58,7 +58,7 @@ D3D7ParticleStream::D3D7ParticleStream (GraphicsClient *_gc, PARTICLESTREAMSPEC d3d7c = (D3D7Client*)_gc; cam_ref = d3d7c->GetScene()->GetCamera()->GetGPos(); src_ref = 0; - src_ofs = _V(0,0,0); + src_ofs = {0,0,0}; interval = 0.1; SetSpecs (pss ? pss : &DefaultParticleStreamSpec); t0 = oapiGetSimTime(); @@ -590,8 +590,8 @@ void ExhaustStream::Update () ((double)rand()/(double)RAND_MAX-0.5)*dv_scale}; dv += vv; - normalise(s); - VECTOR3 vv2 = dv - s*dotp(s,dv); + s = unit(s); + VECTOR3 vv2 = dv - s * dot(s, dv); if (length(vv2)) vv2 *= 0.5*length(vv)/length(vv2); vv2 += s*(((double)rand()/(double)RAND_MAX)*dv_scale); p->vel = vv2*1.0/*2.0*/+av; @@ -675,9 +675,9 @@ void ExhaustStream::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, LPDIRECTDRAWSURFA rad += oapiSurfaceElevation (hPlanet, lng, lat); // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp (sd, pv0); + double fac1 = dot(sd, pv0); if (fac1 > 0.0) return; // shadow doesn't intersect planet surface - double arg = fac1*fac1 - (dotp (pv0, pv0) - rad*rad); + double arg = fac1 * fac1 - (dot(pv0, pv0) - rad * rad); if (arg <= 0.0) return; // shadow doesn't intersect with planet surface double a = -fac1 - sqrt(arg); VECTOR3 shp = sd*a; // projection point in global frame @@ -696,9 +696,9 @@ void ExhaustStream::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, LPDIRECTDRAWSURFA VECTOR3 pvr = p->pos - pp; // rel. particle position // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp (sd, pvr); + double fac1 = dot(sd, pvr); if (fac1 > 0.0) break; // shadow doesn't intersect planet surface - double arg = fac1*fac1 - (dotp (pvr, pvr) - rad*rad); + double arg = fac1 * fac1 - (dot(pvr, pvr) - rad * rad); if (arg <= 0.0) break; // shadow doesn't intersect with planet surface double a = -fac1 - sqrt(arg); @@ -734,7 +734,7 @@ ReentryStream::ReentryStream (oapi::GraphicsClient *_gc, OBJHANDLE hV, PARTICLES : D3D7ParticleStream (_gc, pss) { llevel = 1.0; - Attach (hV, _V(0,0,0), _V(0,0,0), &llevel); + Attach (hV, {0,0,0}, {0,0,0}, &llevel); hPlanet = 0; } diff --git a/OVP/D3D7Client/Scene.cpp b/OVP/D3D7Client/Scene.cpp index bf84755a2..46c19965e 100644 --- a/OVP/D3D7Client/Scene.cpp +++ b/OVP/D3D7Client/Scene.cpp @@ -292,13 +292,13 @@ VECTOR3 Scene::SkyColour () if (cdist < atmp->radlimit) { ATMPARAM prm; oapiGetPlanetAtmParams (hProxy, cdist, &prm); - normalise (rp); - double coss = dotp (pc, rp) / -cdist; + rp = unit(rp); + double coss = dot(pc, rp) / -cdist; double intens = min (1.0,(1.0839*coss+0.4581)) * sqrt (prm.rho/atmp->rho0); // => intensity=0 at sun zenith distance 115° // intensity=1 at sun zenith distance 60° if (intens > 0.0) - col += _V(atmp->color0.x*intens, atmp->color0.y*intens, atmp->color0.z*intens); + col += {atmp->color0.x*intens, atmp->color0.y*intens, atmp->color0.z*intens}; } for (int i = 0; i < 3; i++) if (col.data[i] > 1.0) col.data[i] = 1.0; @@ -450,7 +450,7 @@ void Scene::Render () const std::vector& ls = list[n].marker; VECTOR3 sp; for (j = 0; j < ls.size(); j++) { - if (dotp(ls[j].pos, cpos - ls[j].pos) >= 0.0) { // surface point visible? + if (dot(ls[j].pos, cpos - ls[j].pos) >= 0.0) { // surface point visible? sp = mul(prot, ls[j].pos) + ppos; RenderObjectMarker(pSkp, sp, ls[j].label[0], ls[j].label[1], list[n].shape, size); } @@ -642,8 +642,7 @@ void Scene::RenderVesselShadows (OBJHANDLE hPlanet, float depth) const void Scene::RenderObjectMarker (oapi::Sketchpad* pSkp, const VECTOR3 &gpos, const std::string& label1, const std::string& label2, int mode, int scale) { - VECTOR3 dp (gpos - *cam->GetGPos()); - normalise (dp); + VECTOR3 dp = unit(gpos - *cam->GetGPos()); m_celSphere->RenderMarker(pSkp, dp, label1, label2, mode, scale); } diff --git a/OVP/D3D7Client/SurfMgr.cpp b/OVP/D3D7Client/SurfMgr.cpp index 08e2a796a..bd12560fc 100644 --- a/OVP/D3D7Client/SurfMgr.cpp +++ b/OVP/D3D7Client/SurfMgr.cpp @@ -32,7 +32,7 @@ SurfaceManager::SurfaceManager (const D3D7Client *gclient, const vPlanet *vplane maxlvl = min (*(int*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL), // global setting *(int*)oapiGetObjectParam (obj, OBJPRM_PLANET_SURFACEMAXLEVEL)); // planet-specific setting maxbaselvl = min (8, maxlvl); - pcdir = _V(1,0,0); + pcdir = {1,0,0}; lightfac = *(double*)gc->GetConfigParam (CFGPRM_SURFACELIGHTBRT); spec_base = 0.95f; atmc = oapiGetPlanetAtmConstants (obj); diff --git a/OVP/D3D7Client/TileMgr.cpp b/OVP/D3D7Client/TileMgr.cpp index 24449d4a2..ef503c5c7 100644 --- a/OVP/D3D7Client/TileMgr.cpp +++ b/OVP/D3D7Client/TileMgr.cpp @@ -431,9 +431,8 @@ void TileManager::Render (LPDIRECT3DDEVICE7 dev, D3DMATRIX &wmat, double scale, D3DMAT_Copy (&RenderParam.wmat, &wmat); D3DMAT_Copy (&RenderParam.wmat_tmp, &wmat); D3DMAT_MatrixInvert (&imat, &wmat); - RenderParam.cdir = _V(imat._41, imat._42, imat._43); // camera position in local coordinates (units of planet radii) - RenderParam.cpos = vp->PosFromCamera() * scale; - normalise (RenderParam.cdir); // camera direction + RenderParam.cdir = unit(VECTOR3{imat._41, imat._42, imat._43}); // camera direction + RenderParam.cpos = vp->PosFromCamera() * scale; // camera position in local coordinates (units of planet radii) RenderParam.bfog = bfog; oapiGetRotationMatrix (obj, &RenderParam.grot); @@ -443,11 +442,10 @@ void TileManager::Render (LPDIRECT3DDEVICE7 dev, D3DMATRIX &wmat, double scale, RenderParam.objsize = oapiGetSize (obj); RenderParam.cdist = vp->CamDist() / vp->rad; // camera distance in units of planet radius RenderParam.viewap = (viewap ? viewap : acos (1.0/max (1.0, RenderParam.cdist))); - RenderParam.sdir = tmul (RenderParam.grot, -gpos); - normalise (RenderParam.sdir); // sun direction in planet frame + RenderParam.sdir = unit(tmul(RenderParam.grot, -gpos)); // sun direction in planet frame // limit resolution for fast camera movements - double limitstep, cstep = acos (dotp (RenderParam.cdir, pcdir)); + double limitstep, cstep = std::acos(dot(RenderParam.cdir, pcdir)); int maxlevel = SURF_MAX_PATCHLEVEL; static double limitstep0 = 5.12 * pow(2.0, -(double)SURF_MAX_PATCHLEVEL); for (limitstep = limitstep0; cstep > limitstep && maxlevel > 5; limitstep *= 2.0) @@ -512,7 +510,7 @@ void TileManager::ProcessTile (int lvl, int hemisp, int ilat, int nlat, int ilng static const double rad0 = sqrt(2.0)*PI05*0.5; VECTOR3 cnt = TileCentre (hemisp, ilat, nlat, ilng, nlng); double rad = rad0/(double)nlat; - double adist = acos (dotp (RenderParam.cdir, cnt)) - rad; + double adist = std::acos(dot(RenderParam.cdir, cnt)) - rad; if (adist >= RenderParam.viewap) { tilebuf->DeleteSubTiles (tile); // remove tile descriptions below return; @@ -594,7 +592,7 @@ void TileManager::ProcessTile (int lvl, int hemisp, int ilat, int nlat, int ilng } } else { // actually render the tile at this level - double sdist = acos (dotp (RenderParam.sdir, cnt)); + double sdist = std::acos(dot(RenderParam.sdir, cnt)); if (bCoarseTex) { if (sdist > PI05+rad && bkp_flag & 2) bkp_flag &= 0xFD, bkp_flag |= 1; // supress specular reflection on dark side RenderTile (lvl, hemisp, ilat, nlat, ilng, nlng, sdist, tile, bkp_range, bkp_tex, bkp_ltex, bkp_flag); @@ -665,8 +663,8 @@ VECTOR3 TileManager::TileCentre (int hemisp, int ilat, int nlat, int ilng, int n { double cntlat = PI*0.5 * ((double)ilat+0.5)/(double)nlat, slat = sin(cntlat), clat = cos(cntlat); double cntlng = PI*2.0 * ((double)ilng+0.5)/(double)nlng + PI, slng = sin(cntlng), clng = cos(cntlng); - if (hemisp) return _V(clat*clng, -slat, -clat*slng); - else return _V(clat*clng, slat, clat*slng); + if (hemisp) return {clat*clng, -slat, -clat*slng}; + else return {clat*clng, slat, clat*slng}; } // ======================================================================= @@ -751,7 +749,7 @@ bool TileManager::SpecularColour (D3DCOLORVALUE *col) return false; } else { double fac = 0.7; // needs thought ... - double cosa = dotp (RenderParam.cdir, RenderParam.sdir); + double cosa = dot(RenderParam.cdir, RenderParam.sdir); double alpha = 0.5*acos(cosa); // sun reflection angle double scale = sin(alpha)*fac; col->r = (float)max(0.0, spec_base - scale*atmc->color0.x); diff --git a/OVP/D3D7Client/VBase.cpp b/OVP/D3D7Client/VBase.cpp index 089fc51ab..b953799bb 100644 --- a/OVP/D3D7Client/VBase.cpp +++ b/OVP/D3D7Client/VBase.cpp @@ -203,7 +203,7 @@ bool vBase::Update () if (simt > Tchk) { VECTOR3 pos, sdir; MATRIX3 rot; - oapiGetGlobalPos (hObj, &pos); normalise(pos); + oapiGetGlobalPos (hObj, &pos); pos = unit(pos); oapiGetRotationMatrix (hObj, &rot); sdir = tmul (rot, -pos); double csun = sdir.y; @@ -298,10 +298,10 @@ void vBase::RenderGroundShadow (LPDIRECT3DDEVICE7 dev) oapiGetGlobalPos (hPlanet, &pp); // planet global pos oapiGetGlobalPos (hObj, &sd); // base global pos pvr = sd-pp; // planet-relative base position - d = length (pvr); // planet radius at base location - normalise (sd); // shadow projection direction + d = len(pvr); // planet radius at base location + sd = unit(sd); // shadow projection direction - double fac1 = dotp (sd, pvr); + double fac1 = dot(sd, pvr); if (fac1 > 0.0) // base is on planet night-side return; csun = -fac1/d; // sun elevation above horizon @@ -311,11 +311,11 @@ void vBase::RenderGroundShadow (LPDIRECT3DDEVICE7 dev) MATRIX3 vR; oapiGetRotationMatrix (hObj, &vR); VECTOR3 sdv = tmul (vR, sd); // projection direction in base frame - VECTOR3 hnp = pvr; normalise(hnp); + VECTOR3 hnp = unit(pvr); VECTOR3 hn = tmul (vR, hnp); // horizon normal in vessel frame // perform projections - double nd = dotp (hn, sdv); + double nd = dot(hn, sdv); VECTOR3 sdvs = sdv / nd; if (!sdvs.y) return; // required for plane offset correction @@ -382,7 +382,7 @@ bool vBase::ModLighting (LPD3DLIGHT7 light, double &nextcheck) oapiGetGlobalPos (hS, &GS); // sun position oapiGetGlobalPos (hP, &GP); // planet position S = GS-GB; // sun's position from base - s = length(S); // sun's distance + s = len(S); // sun's distance rs = oapiGetSize (hS); as = asin (rs/s); // apparent radius of sun's disc [rad] double amb = 0; @@ -390,8 +390,8 @@ bool vBase::ModLighting (LPD3DLIGHT7 light, double &nextcheck) // Calculate shadowing by planet P = GP-GB; - p = length(P); - phi = acos (dotp(S,P)/(s*p)); // angular distance between sun and planet + p = len(P); + phi = std::acos(dot(S, P) / (s * p)); // angular distance between sun and planet static const double ap = PI05; // apparent size of planet disc [rad] const ATMCONST *atm = (oapiGetObjectType(hP)==OBJTP_PLANET ? oapiGetPlanetAtmConstants (hP) : NULL); diff --git a/OVP/D3D7Client/VObject.cpp b/OVP/D3D7Client/VObject.cpp index 71301b6de..dc5e48d73 100644 --- a/OVP/D3D7Client/VObject.cpp +++ b/OVP/D3D7Client/VObject.cpp @@ -138,13 +138,13 @@ void vObject::UpdateRenderVectors() double scale = size * *(float*)gc->GetConfigParam(CFGPRM_FRAMEAXISSCALE); double rad = size * 0.01; float alpha = *(float*)gc->GetConfigParam(CFGPRM_FRAMEAXISOPACITY); - AddVector(_V(scale, 0, 0), _V(0, 0, 0), rad, std::string("+x"), _V(1, 1, 1), alpha, D3DRGB(1, 1, 1)); - AddVector(_V(0, scale, 0), _V(0, 0, 0), rad, std::string("+y"), _V(1, 1, 1), alpha, D3DRGB(1, 1, 1)); - AddVector(_V(0, 0, scale), _V(0, 0, 0), rad, std::string("+z"), _V(1, 1, 1), alpha, D3DRGB(1, 1, 1)); + AddVector({scale, 0, 0}, {0, 0, 0}, rad, std::string("+x"), {1, 1, 1}, alpha, D3DRGB(1, 1, 1)); + AddVector({0, scale, 0}, {0, 0, 0}, rad, std::string("+y"), {1, 1, 1}, alpha, D3DRGB(1, 1, 1)); + AddVector({0, 0, scale}, {0, 0, 0}, rad, std::string("+z"), {1, 1, 1}, alpha, D3DRGB(1, 1, 1)); if (flag & FAV_NEGATIVE) { - AddVector(_V(-scale, 0, 0), _V(0, 0, 0), rad, std::string("-x"), _V(1, 1, 1), alpha, D3DRGB(1, 1, 1)); - AddVector(_V(0, -scale, 0), _V(0, 0, 0), rad, std::string("-y"), _V(1, 1, 1), alpha, D3DRGB(1, 1, 1)); - AddVector(_V(0, 0, -scale), _V(0, 0, 0), rad, std::string("-z"), _V(1, 1, 1), alpha, D3DRGB(1, 1, 1)); + AddVector({-scale, 0, 0}, {0, 0, 0}, rad, std::string("-x"), {1, 1, 1}, alpha, D3DRGB(1, 1, 1)); + AddVector({0, -scale, 0}, {0, 0, 0}, rad, std::string("-y"), {1, 1, 1}, alpha, D3DRGB(1, 1, 1)); + AddVector({0, 0, -scale}, {0, 0, 0}, rad, std::string("-z"), {1, 1, 1}, alpha, D3DRGB(1, 1, 1)); } } } @@ -167,7 +167,7 @@ void vObject::RenderSpot (LPDIRECT3DDEVICE7 dev, const VECTOR3 *ofs, float size, float sphi = (float)sin(phi), cphi = (float)cos(phi); const double ambient = 0.2; - double cosa = dotp (unit(gpos), unit(gpos - camp)); + double cosa = dot(unit(gpos), unit(gpos - camp)); double intens = (lighting ? 0.5 * ((1.0-ambient)*cosa + 1.0+ambient) : 1.0); W._11 = (float)bdir.x; @@ -330,7 +330,7 @@ bool vObject::DrawVector(LPDIRECT3DDEVICE7 dev, const VECTOR3& end, const VECTOR VECTOR3 gpos; oapiGetRotationMatrix(hObj, &grot); VECTOR3 cp = tmul(grot, -cpos); - if (dotp(d, unit(end - cp)) > 0) + if (dot(d, unit(end - cp)) > 0) Idx = Idx1, nIdx = nIdx1; else Idx = Idx0, nIdx = nIdx0; diff --git a/OVP/D3D7Client/VPlanet.cpp b/OVP/D3D7Client/VPlanet.cpp index 13df847e9..3321fa017 100644 --- a/OVP/D3D7Client/VPlanet.cpp +++ b/OVP/D3D7Client/VPlanet.cpp @@ -321,7 +321,7 @@ void vPlanet::CheckResolution () void vPlanet::RenderZRange (double *nplane, double *fplane) { - double d = dotp (*scn->GetCamera()->GetGDir(), cpos); + double d = dot(*scn->GetCamera()->GetGDir(), cpos); *fplane = max (1e3, d+rad*1.2); *nplane = max (1e0, d-rad*1.2); *fplane = min (*fplane, *nplane*1e5); @@ -411,7 +411,7 @@ bool vPlanet::Render (LPDIRECT3DDEVICE7 dev) // day/nighttime fog lighting VECTOR3 ppos; oapiGetGlobalPos (hObj, &ppos); - double cosa = dotp (unit(ppos), unit(cpos)); + double cosa = dot(unit(ppos), unit(cpos)); double bright = 1.0 * max (0.0, min (1.0, cosa + 0.3)); float rfog = (float)(bright*(min(1.0,fogcol.x)+0.0)); // "whiten" the fog colour float gfog = (float)(bright*(min(1.0,fogcol.y)+0.0)); @@ -738,7 +738,7 @@ bool vPlanet::ModLighting (DWORD &ambient) if (!prm.bAtm) return false; if (cdist >= size+prm.atm_href) return false; - double alpha = acos (dotp (unit(*scn->GetCamera()->GetGPos()), -unit(cpos))); + double alpha = std::acos(dot(unit(*scn->GetCamera()->GetGPos()), -unit(cpos))); // angular distance between sun and planet as seen from camera double sunelev = alpha - PI05; // elevation of sun above horizon (assuming camera on ground) diff --git a/OVP/D3D7Client/VVessel.cpp b/OVP/D3D7Client/VVessel.cpp index a39428973..988c6a32b 100644 --- a/OVP/D3D7Client/VVessel.cpp +++ b/OVP/D3D7Client/VVessel.cpp @@ -147,32 +147,32 @@ void vVessel::UpdateRenderVectors() if ((flag & BFV_WEIGHT) && vessel->GetWeightVector(F)) { sprintf(cbuf, "G = %fN", len = length(F)); if (logscale) len = log(len + shift) - lshift; else len *= scale; - AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2, std::string(cbuf), _V(1, 1, 0), alpha, D3DRGB(1, 1, 0)); + AddVector(unit(F) * (len * pscale), {0, 0, 0}, scale2, std::string(cbuf), {1, 1, 0}, alpha, D3DRGB(1, 1, 0)); } if ((flag & BFV_THRUST) && vessel->GetThrustVector(F)) { sprintf(cbuf, "T = %fN", len = length(F)); if (logscale) len = log(len + shift) - lshift; else len *= scale; - AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2, std::string(cbuf), _V(0, 0, 1), alpha, D3DRGB(0.5, 0.5, 1)); + AddVector(unit(F) * (len * pscale), {0, 0, 0}, scale2, std::string(cbuf), {0, 0, 1}, alpha, D3DRGB(0.5, 0.5, 1)); } if ((flag & BFV_LIFT) && vessel->GetLiftVector(F)) { sprintf(cbuf, "L = %fN", len = length(F)); if (logscale) len = log(len + shift) - lshift; else len *= scale; - AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2, std::string(cbuf), _V(0, 1, 0), alpha, D3DRGB(0.5, 1, 0.5)); + AddVector(unit(F) * (len * pscale), {0, 0, 0}, scale2, std::string(cbuf), {0, 1, 0}, alpha, D3DRGB(0.5, 1, 0.5)); } if ((flag & BFV_DRAG) && vessel->GetDragVector(F)) { sprintf(cbuf, "D = %fN", len = length(F)); if (logscale) len = log(len + shift) - lshift; else len *= scale; - AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2, std::string(cbuf), _V(1, 0, 0), alpha, D3DRGB(1, 0.5, 0.5)); + AddVector(unit(F) * (len * pscale), {0, 0, 0}, scale2, std::string(cbuf), {1, 0, 0}, alpha, D3DRGB(1, 0.5, 0.5)); } if ((flag & BFV_TOTAL) && vessel->GetForceVector(F)) { sprintf(cbuf, "F = %fN", len = length(F)); if (logscale) len = log(len + shift) - lshift; else len *= scale; - AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2, std::string(cbuf), _V(1, 1, 1), alpha, D3DRGB(1, 1, 1)); + AddVector(unit(F) * (len * pscale), {0, 0, 0}, scale2, std::string(cbuf), {1, 1, 1}, alpha, D3DRGB(1, 1, 1)); } if ((flag & BFV_TORQUE) && vessel->GetTorqueVector(F)) { sprintf(cbuf, "M = %fNm", len = length(F)); if (logscale) len = log(len + 1e-5) - log(1e-5); else len *= scale * 1e5; - AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2 * 0.5, std::string(cbuf), _V(1, 0, 1), alpha, D3DRGB(1, 0, 1)); + AddVector(unit(F) * (len * pscale), {0, 0, 0}, scale2 * 0.5, std::string(cbuf), {1, 0, 1}, alpha, D3DRGB(1, 0, 1)); } } } @@ -535,16 +535,16 @@ void vVessel::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, OBJHANDLE hPlanet) alt = d-R; // altitude above surface if (alt*eps > vessel->GetSize()) // too high to cast a shadow return; - normalise (sd); // shadow projection direction + sd = unit(sd); // shadow projection direction // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp (sd, pvr); + double fac1 = dot(sd, pvr); if (fac1 > 0.0) // shadow doesn't intersect planet surface return; double csun = -fac1/d; // sun elevation above horizon if (csun < shadow_elev_limit) // sun too low to cast shadow return; - double arg = fac1*fac1 - (dotp (pvr, pvr) - R*R); + double arg = fac1 * fac1 - (dot(pvr, pvr) - R * R); if (arg <= 0.0) // shadow doesn't intersect with planet surface return; double a = -fac1 - sqrt(arg); @@ -557,8 +557,8 @@ void vVessel::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, OBJHANDLE hPlanet) vessel->HorizonInvRot (hnp, hn); // perform projections - double nr0 = dotp (hn, shp); - double nd = dotp (hn, sdv); + double nr0 = dot(hn, shp); + double nd = dot(hn, sdv); VECTOR3 sdvs = sdv / nd; DWORD j; @@ -629,8 +629,8 @@ void vVessel::SetExhaustVertices (const VECTOR3 &edir, const VECTOR3 &cdir, cons { // need to rotate the billboard so it faces the observer const float flarescale = 7.0; - VECTOR3 sdir = crossp (cdir, edir); normalise (sdir); - VECTOR3 tdir = crossp (cdir, sdir); normalise (tdir); + VECTOR3 sdir = unit(cross(cdir, edir)); + VECTOR3 tdir = unit(cross(cdir, sdir)); D3DVALUE rx = (D3DVALUE)ref.x, ry = (D3DVALUE)ref.y, rz = (D3DVALUE)ref.z; D3DVALUE sx = (D3DVALUE)(sdir.x*wscale); D3DVALUE sy = (D3DVALUE)(sdir.y*wscale); @@ -684,7 +684,7 @@ bool vVessel::ModLighting (LPD3DLIGHT7 light) double p = length(P); if (p < s) { // shadow only if planet closer than sun double psize = oapiGetSize(hP); - double phi = acos (dotp(S,P)/(s*p)); // angular distance between sun and planet + double phi = std::acos(dot(S, P) / (s * p)); // angular distance between sun and planet double ap = (psize < p ? asin(psize / p) : PI05); // apparent size of planet disc [rad] const ATMCONST *atm = (oapiGetObjectType(hP)==OBJTP_PLANET ? oapiGetPlanetAtmConstants (hP) : NULL); diff --git a/OVP/D3D7Client/spherepatch.cpp b/OVP/D3D7Client/spherepatch.cpp index 405225779..ed77fad25 100644 --- a/OVP/D3D7Client/spherepatch.cpp +++ b/OVP/D3D7Client/spherepatch.cpp @@ -206,9 +206,9 @@ void CreateSpherePatch (const oapi::D3D7Client *gclient, VBMESH &mesh, int nlng, double clng0 = cos(minlng), slng0 = sin(minlng); double clat1 = cos(maxlat), slat1 = sin(maxlat); double clng1 = cos(maxlng), slng1 = sin(maxlng); - VECTOR3 ex = {clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}; normalise(ex); - VECTOR3 ey = {0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}; normalise(ey); - VECTOR3 ez = crossp (ey, ex); + auto ex = unit(VECTOR3{clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}); + auto ey = unit(VECTOR3{0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}); + auto ez = cross(ey, ex); MATRIX3 R = {ex.x, ex.y, ex.z, ey.x, ey.y, ey.z, ez.x, ez.y, ez.z}; VECTOR3 pref = {0.5*(clat0*clng1 + clat0*clng0), slat0, 0.5*(clat0*slng1 + clat0*slng0)}; // origin VECTOR3 tpmin, tpmax; @@ -226,7 +226,7 @@ void CreateSpherePatch (const oapi::D3D7Client *gclient, VBMESH &mesh, int nlng, for (j = 0; j <= nseg; j++) { lng = (nseg ? minlng + (maxlng-minlng) * (double)j/(double)nseg : 0.0); slng = sin(lng), clng = cos(lng); - pos = _V(clat*clng, slat, clat*slng); + pos = {clat*clng, slat, clat*slng}; tpos = mul (R, pos-pref); if (!n) { tpmin = tpos; @@ -312,21 +312,21 @@ void CreateSpherePatch (const oapi::D3D7Client *gclient, VBMESH &mesh, int nlng, } // transform bounding box back to patch coordinates - pos = tmul (R, _V(tpmin.x, tpmin.y, tpmin.z)) + pref; + pos = tmul (R, {tpmin.x, tpmin.y, tpmin.z}) + pref; V[0].x = D3DVAL(pos.x); V[0].y = D3DVAL(pos.y); V[0].z = D3DVAL(pos.z); - pos = tmul (R, _V(tpmax.x, tpmin.y, tpmin.z)) + pref; + pos = tmul (R, {tpmax.x, tpmin.y, tpmin.z}) + pref; V[1].x = D3DVAL(pos.x); V[1].y = D3DVAL(pos.y); V[1].z = D3DVAL(pos.z); - pos = tmul (R, _V(tpmin.x, tpmax.y, tpmin.z)) + pref; + pos = tmul (R, {tpmin.x, tpmax.y, tpmin.z}) + pref; V[2].x = D3DVAL(pos.x); V[2].y = D3DVAL(pos.y); V[2].z = D3DVAL(pos.z); - pos = tmul (R, _V(tpmax.x, tpmax.y, tpmin.z)) + pref; + pos = tmul (R, {tpmax.x, tpmax.y, tpmin.z}) + pref; V[3].x = D3DVAL(pos.x); V[3].y = D3DVAL(pos.y); V[3].z = D3DVAL(pos.z); - pos = tmul (R, _V(tpmin.x, tpmin.y, tpmax.z)) + pref; + pos = tmul (R, {tpmin.x, tpmin.y, tpmax.z}) + pref; V[4].x = D3DVAL(pos.x); V[4].y = D3DVAL(pos.y); V[4].z = D3DVAL(pos.z); - pos = tmul (R, _V(tpmax.x, tpmin.y, tpmax.z)) + pref; + pos = tmul (R, {tpmax.x, tpmin.y, tpmax.z}) + pref; V[5].x = D3DVAL(pos.x); V[5].y = D3DVAL(pos.y); V[5].z = D3DVAL(pos.z); - pos = tmul (R, _V(tpmin.x, tpmax.y, tpmax.z)) + pref; + pos = tmul (R, {tpmin.x, tpmax.y, tpmax.z}) + pref; V[6].x = D3DVAL(pos.x); V[6].y = D3DVAL(pos.y); V[6].z = D3DVAL(pos.z); - pos = tmul (R, _V(tpmax.x, tpmax.y, tpmax.z)) + pref; + pos = tmul (R, {tpmax.x, tpmax.y, tpmax.z}) + pref; V[7].x = D3DVAL(pos.x); V[7].y = D3DVAL(pos.y); V[7].z = D3DVAL(pos.z); mesh.bb->Unlock (); } diff --git a/OVP/D3D7Client/surfmgr2.cpp b/OVP/D3D7Client/surfmgr2.cpp index 4a29b7956..4f62311b1 100644 --- a/OVP/D3D7Client/surfmgr2.cpp +++ b/OVP/D3D7Client/surfmgr2.cpp @@ -476,7 +476,7 @@ void SurfTile::Render () bool has_shadows = false; bool has_lights = false; if (ltex || render_shadows) { - sdist = acos (dotp (mgr->prm.sdir, cnt)); + sdist = std::acos(dot(mgr->prm.sdir, cnt)); rad = rad0/(double)(2<pos; - if (dotp (renderlabel[i]->pos, camlabelpos) >= 0.0) { - double fontscale = 1e4/length(camlabelpos)*(13-min(tile->lvl,12)*1); + if (dot(renderlabel[i]->pos, camlabelpos) >= 0.0) { + double fontscale = 1e4 / len(camlabelpos) * (13 - min(tile->lvl, 12) * 1); int idx = max(0, min(3, (int)fontscale)); if (idx != *fontidx) { skp->SetFont(labelfont[idx]); diff --git a/OVP/D3D7Client/tilemgr2.cpp b/OVP/D3D7Client/tilemgr2.cpp index 20e2764f6..0451b6461 100644 --- a/OVP/D3D7Client/tilemgr2.cpp +++ b/OVP/D3D7Client/tilemgr2.cpp @@ -138,7 +138,7 @@ VECTOR3 Tile::Centre () const int nlng = 2 << lvl; double cntlat = PI05 - PI * ((double)ilat+0.5)/(double)nlat, slat = sin(cntlat), clat = cos(cntlat); double cntlng = PI2 * ((double)ilng+0.5)/(double)nlng + PI, slng = sin(cntlng), clng = cos(cntlng); - return _V(clat*clng, slat, clat*slng); + return {clat*clng, slat, clat*slng}; } @@ -190,9 +190,9 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, INT16 *elev, double double clng0 = cos(minlng), slng0 = sin(minlng); double clat1 = cos(maxlat), slat1 = sin(maxlat); double clng1 = cos(maxlng), slng1 = sin(maxlng); - VECTOR3 ex = {clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}; normalise (ex); - VECTOR3 ey = {0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}; normalise (ey); - VECTOR3 ez = crossp (ey, ex); + auto ex = unit(VECTOR3{clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}); + auto ey = unit(VECTOR3{0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}); + auto ez = cross(ey, ex); MATRIX3 R = {ex.x, ex.y, ex.z, ey.x, ey.y, ey.z, ez.x, ez.y, ez.z}; VECTOR3 pref = {radius*clat0*0.5*(clng1+clng0), radius*slat0, radius*clat0*0.5*(slng1+slng0)}; // origin VECTOR3 tpmin, tpmax; @@ -220,7 +220,7 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, INT16 *elev, double eradius = radius + globelev; // radius including node elevation if (elev) eradius += (double)elev[(i+1)*TILE_ELEVSTRIDE + j+1]*elev_scale; - nml = _V(clat*clng, slat, clat*slng); + nml = {clat*clng, slat, clat*slng}; pos = nml*eradius; tpos = mul (R, pos-pref); if (!n) { @@ -322,8 +322,7 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, INT16 *elev, double // This version avoids the normalisation of the 4 intermediate face normals // It's faster and doesn't seem to make much difference - VECTOR3 nml = {2.0*dydz, dz*elev_scale*(elev[en-TILE_ELEVSTRIDE]-elev[en+TILE_ELEVSTRIDE]), dy*elev_scale*(elev[en-1]-elev[en+1])}; - normalise (nml); + auto nml = unit(VECTOR3{2.0*dydz, dz*elev_scale*(elev[en-TILE_ELEVSTRIDE]-elev[en+TILE_ELEVSTRIDE]), dy*elev_scale*(elev[en-1]-elev[en+1])}); // rotate into place nx1 = nml.x*clat - nml.y*slat; ny1 = nml.x*slat + nml.y*clat; @@ -365,14 +364,14 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, INT16 *elev, double pref.x -= dx; pref.y -= dy; mesh->bbvtx = new VECTOR4[8]; - mesh->bbvtx[0] = _V(tmul (R, _V(tpmin.x, tpmin.y, tpmin.z)) + pref); - mesh->bbvtx[1] = _V(tmul (R, _V(tpmax.x, tpmin.y, tpmin.z)) + pref); - mesh->bbvtx[2] = _V(tmul (R, _V(tpmin.x, tpmax.y, tpmin.z)) + pref); - mesh->bbvtx[3] = _V(tmul (R, _V(tpmax.x, tpmax.y, tpmin.z)) + pref); - mesh->bbvtx[4] = _V(tmul (R, _V(tpmin.x, tpmin.y, tpmax.z)) + pref); - mesh->bbvtx[5] = _V(tmul (R, _V(tpmax.x, tpmin.y, tpmax.z)) + pref); - mesh->bbvtx[6] = _V(tmul (R, _V(tpmin.x, tpmax.y, tpmax.z)) + pref); - mesh->bbvtx[7] = _V(tmul (R, _V(tpmax.x, tpmax.y, tpmax.z)) + pref); + mesh->bbvtx[0] = _V(tmul (R, {tpmin.x, tpmin.y, tpmin.z}) + pref); + mesh->bbvtx[1] = _V(tmul (R, {tpmax.x, tpmin.y, tpmin.z}) + pref); + mesh->bbvtx[2] = _V(tmul (R, {tpmin.x, tpmax.y, tpmin.z}) + pref); + mesh->bbvtx[3] = _V(tmul (R, {tpmax.x, tpmax.y, tpmin.z}) + pref); + mesh->bbvtx[4] = _V(tmul (R, {tpmin.x, tpmin.y, tpmax.z}) + pref); + mesh->bbvtx[5] = _V(tmul (R, {tpmax.x, tpmin.y, tpmax.z}) + pref); + mesh->bbvtx[6] = _V(tmul (R, {tpmin.x, tpmax.y, tpmax.z}) + pref); + mesh->bbvtx[7] = _V(tmul (R, {tpmax.x, tpmax.y, tpmax.z}) + pref); mesh->MapVertices (TileManager2Base::d3d, TileManager2Base::dev, TileManager2Base::vbMemCaps); // TODO return mesh; @@ -417,7 +416,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, INT16 *elev, double globelev) slng = sin(lng), clng = cos(lng); eradius = radius + globelev; // radius including node elevation if (elev) eradius += (double)elev[(grd+1-y)*TILE_ELEVSTRIDE + x+1]; - nml = _V(slat*clng, clat, slat*slng); + nml = {slat*clng, clat, slat*slng}; pos = nml*eradius; vtx->x = D3DVAL(pos.x); vtx->nx = D3DVAL(nml.x); vtx->y = D3DVAL(pos.y); vtx->ny = D3DVAL(nml.y); @@ -450,7 +449,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, INT16 *elev, double globelev) for (x = 0; x < x2; x++) mn += (double)elev[TILE_ELEVSTRIDE*(grd+1) + x+1]; eradius += mn/x2; } - nml = _V(0,1,0); + nml = {0,1,0}; pos = nml*eradius; vtx->x = D3DVAL(pos.x); vtx->nx = D3DVAL(nml.x); vtx->y = D3DVAL(pos.y); vtx->ny = D3DVAL(nml.y); @@ -468,7 +467,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, INT16 *elev, double globelev) for (x = 0; x < x2; x++) mn += (double)elev[TILE_ELEVSTRIDE + x+1]; eradius += mn/x2; } - nml = _V(0,-1,0); + nml = {0,-1,0}; pos = nml*eradius; vtx->x = D3DVAL(pos.x); vtx->nx = D3DVAL(nml.x); vtx->y = D3DVAL(pos.y); vtx->ny = D3DVAL(nml.y); @@ -516,8 +515,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, INT16 *elev, double globelev) if (!ilng) lng -= PI; slng = sin(lng), clng = cos(lng); en = (grd+1-y)*TILE_ELEVSTRIDE + x+1; - VECTOR3 nml = {2.0*dydz, dz*(elev[en-TILE_ELEVSTRIDE]-elev[en+TILE_ELEVSTRIDE]), dy*(elev[en-1]-elev[en+1])}; - normalise(nml); + auto nml = unit(VECTOR3{2.0*dydz, dz*(elev[en-TILE_ELEVSTRIDE]-elev[en+TILE_ELEVSTRIDE]), dy*(elev[en-1]-elev[en+1])}); // rotate into place nx1 = nml.x*clat - nml.y*slat; ny1 = nml.x*slat + nml.y*clat; @@ -794,11 +792,10 @@ void TileManager2Base::SetRenderPrm (MATRIX4 &dwmat, double prerot, bool use_zbu prm.dwmat_tmp = prm.dwmat; prm.cpos = obj_pos-cam_pos; prm.cdir = tmul (prm.grot, -prm.cpos); // camera's direction in planet frame - double cdist = length(prm.cdir); + double cdist = len(prm.cdir); prm.cdist = cdist / obj_size; // camera's distance in units of planet radius - normalise (prm.cdir); - prm.sdir = tmul (prm.grot, -obj_pos); // sun's direction in planet frame - normalise (prm.sdir); + prm.cdir = unit(prm.cdir); + prm.sdir = unit(tmul (prm.grot, -obj_pos)); // sun's direction in planet frame prm.viewap = acos (1.0/(max (prm.cdist, 1.0+minalt))); prm.scale = 1.0; prm.fog = rprm.bFog; diff --git a/OVP/D3D7Client/tilemgr2_imp.hpp b/OVP/D3D7Client/tilemgr2_imp.hpp index 7f20d1213..aed1be6d3 100644 --- a/OVP/D3D7Client/tilemgr2_imp.hpp +++ b/OVP/D3D7Client/tilemgr2_imp.hpp @@ -94,7 +94,7 @@ void TileManager2Base::ProcessNode (QuadTreeNode *node) VECTOR3 &cnt = tile->cnt; // tile centre in unit planet frame static const double rad0 = sqrt(2.0)*PI05; double rad = rad0/(double)nlat; - double alpha = acos (dotp (prm.cdir, cnt)); // angle between tile centre and camera from planet centre + double alpha = std::acos(dot(prm.cdir, cnt)); // angle between tile centre and camera from planet centre double adist = alpha - rad; // angle between closest tile corner and camera if (adist >= prm.viewap) { if (lvl == 0) diff --git a/OVP/D3D9Client/AABBUtil.cpp b/OVP/D3D9Client/AABBUtil.cpp index e7531ad71..0dd2598ec 100644 --- a/OVP/D3D9Client/AABBUtil.cpp +++ b/OVP/D3D9Client/AABBUtil.cpp @@ -17,9 +17,8 @@ // ================================================================================================================================= #include "AABBUtil.h" -#include "OrbiterAPI.h" -#include "VectorHelpers.h" #include "Log.h" +#include "OrbiterAPI.h" #pragma warning(push) #pragma warning(disable : 4838) diff --git a/OVP/D3D9Client/AtmoControls.h b/OVP/D3D9Client/AtmoControls.h index 451d05403..35baa229f 100644 --- a/OVP/D3D9Client/AtmoControls.h +++ b/OVP/D3D9Client/AtmoControls.h @@ -10,6 +10,9 @@ #define ATM_SLIDER_COUNT 20 +#include "DrawAPI.h" + +using oapi::FVECTOR3; typedef struct ScatterParams { ScatterParams(); ///< Defaut c'tor diff --git a/OVP/D3D9Client/CMakeLists.txt b/OVP/D3D9Client/CMakeLists.txt index 8e89c0e60..447113722 100644 --- a/OVP/D3D9Client/CMakeLists.txt +++ b/OVP/D3D9Client/CMakeLists.txt @@ -108,7 +108,6 @@ set(IncludeFiles TileMgr.h Tilemgr2.h VBase.h - VectorHelpers.h VideoTab.h VObject.h VPlanet.h diff --git a/OVP/D3D9Client/CSphereMgr.cpp b/OVP/D3D9Client/CSphereMgr.cpp index 6f8769e8a..18e78cf38 100644 --- a/OVP/D3D9Client/CSphereMgr.cpp +++ b/OVP/D3D9Client/CSphereMgr.cpp @@ -426,7 +426,7 @@ void CSphereManager::Render (LPDIRECT3DDEVICE9 dev, int level, double bglvl) rcam = mul(ecl2gal, rcam); - RenderParam.camdir = _V(rcam.m13, rcam.m23, rcam.m33); + RenderParam.camdir = {rcam.m13, rcam.m23, rcam.m33}; WaitForSingleObject (tilebuf->hQueueMutex, INFINITE); @@ -434,7 +434,7 @@ void CSphereManager::Render (LPDIRECT3DDEVICE9 dev, int level, double bglvl) CelFlow.bBeta = m_bStarImg; CelData.fAlpha = intens; CelData.fBeta = bgscale; - CelData.mViewProj = *scn->GetProjectionViewMatrix(); + CelData.mViewProj = to_FMATRIX4(*scn->GetProjectionViewMatrix()); pShader->Setup(pPatchVertexDecl, false, 0); pShader->ClearTextures(); @@ -468,7 +468,7 @@ void CSphereManager::ProcessTile (int lvl, int hemisp, int ilat, int nlat, int i static const double rad0 = sqrt(2.0)*PI05; VECTOR3 cnt = TileCentre (hemisp, ilat, nlat, ilng, nlng); double rad = rad0/(double)nlat; - double alpha = acos (dotp (RenderParam.camdir, cnt)); + double alpha = std::acos(dot(RenderParam.camdir, cnt)); double adist = alpha - rad; if (adist > RenderParam.viewap) return; @@ -502,8 +502,8 @@ void CSphereManager::RenderTile (int lvl, int hemisp, int ilat, int nlat, int il VBMESH &mesh = PATCH_TPL[lvl][ilat]; // patch template D3D9Stats.Old.Tiles[lvl]++; - - CelData.mWorld = mWorld; + + CelData.mWorld = to_FMATRIX4(mWorld); pShader->SetTexture(hTexA, tex, IPF_CLAMP | IPF_ANISOTROPIC); pShader->SetTexture(hTexB, ltex, IPF_CLAMP | IPF_ANISOTROPIC); @@ -524,8 +524,8 @@ VECTOR3 CSphereManager::TileCentre (int hemisp, int ilat, int nlat, int ilng, in { double cntlat = PI05 * ((double)ilat+0.5)/(double)nlat, slat = sin(cntlat), clat = cos(cntlat); double cntlng = PI2 * ((double)ilng+0.5)/(double)nlng + PI, slng = sin(cntlng), clng = cos(cntlng); - if (hemisp) return _V(clat*clng, -slat, -clat*slng); - else return _V(clat*clng, slat, clat*slng); + if (hemisp) return {clat*clng, -slat, -clat*slng}; + else return {clat*clng, slat, clat*slng}; } // ======================================================================= diff --git a/OVP/D3D9Client/CelSphere.cpp b/OVP/D3D9Client/CelSphere.cpp index 805feb1c0..21c9c006b 100644 --- a/OVP/D3D9Client/CelSphere.cpp +++ b/OVP/D3D9Client/CelSphere.cpp @@ -332,11 +332,11 @@ void D3D9CelestialSphere::Render(LPDIRECT3DDEVICE9 pDevice, const VECTOR3& skyCo // render ecliptic grid if (renderFlag & PLN_EGRID) { FVECTOR4 baseCol1(0.0f, 0.2f, 0.3f, 1.0f); - D3DXVECTOR4 vColor1 = ColorAdjusted(baseCol1); + auto vColor1 = to_D3DXVECTOR4(ColorAdjusted(baseCol1)); HR(s_FX->SetVector(s_eColor, &vColor1)); RenderGrid(s_FX, false); FVECTOR4 baseCol2(0.0f, 0.4f, 0.6f, 1.0f); - D3DXVECTOR4 vColor2 = ColorAdjusted(baseCol2); + auto vColor2 = to_D3DXVECTOR4(ColorAdjusted(baseCol2)); HR(s_FX->SetVector(s_eColor, &vColor2)); RenderGreatCircle(s_FX); MATRIX3 ident = _M(1, 0, 0, 0, 1, 0, 0, 0, 1); @@ -355,11 +355,11 @@ void D3D9CelestialSphere::Render(LPDIRECT3DDEVICE9 pDevice, const VECTOR3& skyCo D3DXMatrixMultiply(&rot, &T, m_scene->GetProjectionViewMatrix()); HR(s_FX->SetMatrix(s_eWVP, &rot)); FVECTOR4 baseCol1(0.3f, 0.0f, 0.0f, 1.0f); - D3DXVECTOR4 vColor1 = ColorAdjusted(baseCol1); + auto vColor1 = to_D3DXVECTOR4(ColorAdjusted(baseCol1)); HR(s_FX->SetVector(s_eColor, &vColor1)); RenderGrid(s_FX, false); FVECTOR4 baseCol2(0.7f, 0.0f, 0.0f, 1.0f); - D3DXVECTOR4 vColor2 = ColorAdjusted(baseCol2); + auto vColor2 = to_D3DXVECTOR4(ColorAdjusted(baseCol2)); HR(s_FX->SetVector(s_eColor, &vColor2)); RenderGreatCircle(s_FX); double dphi = ElevationScaleRotation(R); @@ -374,11 +374,11 @@ void D3D9CelestialSphere::Render(LPDIRECT3DDEVICE9 pDevice, const VECTOR3& skyCo D3DXMatrixMultiply(&rot, &m_transformCelestial, m_scene->GetProjectionViewMatrix()); HR(s_FX->SetMatrix(s_eWVP, &rot)); FVECTOR4 baseCol1(0.3f, 0.0f, 0.3f, 1.0f); - D3DXVECTOR4 vColor1 = ColorAdjusted(baseCol1); + auto vColor1 = to_D3DXVECTOR4(ColorAdjusted(baseCol1)); HR(s_FX->SetVector(s_eColor, &vColor1)); RenderGrid(s_FX, false); FVECTOR4 baseCol2(0.7f, 0.0f, 0.7f, 1.0f); - D3DXVECTOR4 vColor2 = ColorAdjusted(baseCol2); + auto vColor2 = to_D3DXVECTOR4(ColorAdjusted(baseCol2)); HR(s_FX->SetVector(s_eColor, &vColor2)); RenderGreatCircle(s_FX); double dphi = ElevationScaleRotation(m_rotCelestial); @@ -393,11 +393,11 @@ void D3D9CelestialSphere::Render(LPDIRECT3DDEVICE9 pDevice, const VECTOR3& skyCo D3DXMatrixMultiply(&rot, &T, m_scene->GetProjectionViewMatrix()); HR(s_FX->SetMatrix(s_eWVP, &rot)); oapi::FVECTOR4 baseCol1(0.2f, 0.2f, 0.0f, 1.0f); - D3DXVECTOR4 vColor1 = ColorAdjusted(baseCol1); + auto vColor1 = to_D3DXVECTOR4(ColorAdjusted(baseCol1)); HR(s_FX->SetVector(s_eColor, &vColor1)); RenderGrid(s_FX, false); oapi::FVECTOR4 baseCol2(0.5f, 0.5f, 0.0f, 1.0f); - D3DXVECTOR4 vColor2 = ColorAdjusted(baseCol2); + auto vColor2 = to_D3DXVECTOR4(ColorAdjusted(baseCol2)); HR(s_FX->SetVector(s_eColor, &vColor2)); RenderGreatCircle(s_FX); double dphi = ElevationScaleRotation(R); @@ -421,7 +421,7 @@ void D3D9CelestialSphere::Render(LPDIRECT3DDEVICE9 pDevice, const VECTOR3& skyCo D3DXMatrixMultiply(&rot, &iR, m_scene->GetProjectionViewMatrix()); HR(s_FX->SetMatrix(s_eWVP, &rot)); FVECTOR4 baseCol(0.0f, 0.6f, 0.0f, 1.0f); - D3DXVECTOR4 vColor = ColorAdjusted(baseCol); + auto vColor = to_D3DXVECTOR4(ColorAdjusted(baseCol)); HR(s_FX->SetVector(s_eColor, &vColor)); RenderGreatCircle(s_FX); } @@ -497,7 +497,7 @@ void D3D9CelestialSphere::RenderStars(ID3DXEffect *FX) void D3D9CelestialSphere::RenderConstellationLines(ID3DXEffect *FX) { const FVECTOR4 baseCol(0.5f, 0.3f, 0.2f, 1.0f); - D3DXVECTOR4 vColor = ColorAdjusted(baseCol); + auto vColor = to_D3DXVECTOR4(ColorAdjusted(baseCol)); HR(s_FX->SetVector(s_eColor, &vColor)); _TRACE; @@ -516,7 +516,7 @@ void D3D9CelestialSphere::RenderConstellationLines(ID3DXEffect *FX) void D3D9CelestialSphere::RenderConstellationBoundaries(ID3DXEffect* FX) { const FVECTOR4 baseCol(0.25f, 0.2f, 0.15f, 1.0f); - D3DXVECTOR4 vColor = ColorAdjusted(baseCol); + auto vColor = to_D3DXVECTOR4(ColorAdjusted(baseCol)); HR(s_FX->SetVector(s_eColor, &vColor)); _TRACE; diff --git a/OVP/D3D9Client/CloudMgr.cpp b/OVP/D3D9Client/CloudMgr.cpp index dbe9d6dd6..3b1f4e8e3 100644 --- a/OVP/D3D9Client/CloudMgr.cpp +++ b/OVP/D3D9Client/CloudMgr.cpp @@ -33,7 +33,7 @@ CloudManager::CloudManager(D3D9Client *gclient, const vPlanet *vplanet) maxlvl = min (*(int*)gc->GetConfigParam (CFGPRM_SURFACEMAXLEVEL), // global setting *(int*)oapiGetObjectParam (obj, OBJPRM_PLANET_SURFACEMAXLEVEL)); // planet-specific setting maxbaselvl = min (8, maxlvl); - pcdir = _V(1,0,0); + pcdir = {1,0,0}; lightfac = *(double*)gc->GetConfigParam (CFGPRM_SURFACELIGHTBRT); nmask = 0; nhitex = nhispec = 0; diff --git a/OVP/D3D9Client/Cloudmgr2.cpp b/OVP/D3D9Client/Cloudmgr2.cpp index 43f313dac..686ff150d 100644 --- a/OVP/D3D9Client/Cloudmgr2.cpp +++ b/OVP/D3D9Client/Cloudmgr2.cpp @@ -112,7 +112,7 @@ void CloudTile::Render() sp->vMicroOff = GetTexRangeDX(µrange); sp->fAlpha = 1.0f; sp->fBeta = 1.0f; - sp->mWorld = mWorld; + sp->mWorld = to_FMATRIX4(mWorld); // ------------------------------------------------------------------- // render surface mesh diff --git a/OVP/D3D9Client/D3D9Client.cpp b/OVP/D3D9Client/D3D9Client.cpp index ddb836442..014bfca0d 100644 --- a/OVP/D3D9Client/D3D9Client.cpp +++ b/OVP/D3D9Client/D3D9Client.cpp @@ -1683,7 +1683,7 @@ LRESULT D3D9Client::RenderWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l xpos = GET_X_LPARAM(lParam); ypos = GET_Y_LPARAM(lParam); - GetScene()->vPickRay = GetScene()->GetPickingRay(xpos, ypos); + GetScene()->vPickRay = to_FVECTOR3( GetScene()->GetPickingRay(xpos, ypos) ); TRACKMOUSEEVENT te; te.cbSize = sizeof(TRACKMOUSEEVENT); te.dwFlags = TME_LEAVE; te.hwndTrack = hRenderWnd; TrackMouseEvent(&te); @@ -1790,7 +1790,7 @@ LRESULT D3D9Client::RenderWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l if (d>1) d=1; double speed = *(double *)GetConfigParam(CFGPRM_GETCAMERASPEED); speed *= (DebugControls::GetVisualSize()/100.0); - if (scene->CameraPan(_V(0,0,double(d))*2.0, speed)) return 0; + if (scene->CameraPan(VECTOR3{0, 0, double(d)} * 2.0, speed)) return 0; } PickTerrain(uMsg, xpos, ypos); @@ -1810,7 +1810,7 @@ LRESULT D3D9Client::RenderWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l if (bTrackMouse) { double speed = *(double *)GetConfigParam(CFGPRM_GETCAMERASPEED); speed *= (DebugControls::GetVisualSize() / 100.0); - if (scene->CameraPan(_V(-x, y, 0)*0.05, speed)) return 0; + if (scene->CameraPan(VECTOR3{-x, y, 0} * 0.05, speed)) return 0; } } diff --git a/OVP/D3D9Client/D3D9Effect.cpp b/OVP/D3D9Client/D3D9Effect.cpp index 8c40c0f18..ef434d073 100644 --- a/OVP/D3D9Client/D3D9Effect.cpp +++ b/OVP/D3D9Client/D3D9Effect.cpp @@ -5,13 +5,13 @@ // Copyright (C) 2011 - 2016 Jarmo Nikkanen // =========================================================================================== +#include "D3D9Config.h" #include "D3D9Effect.h" -#include "Log.h" -#include "Scene.h" #include "D3D9Surface.h" -#include "D3D9Config.h" +#include "D3D9Util.h" +#include "Log.h" #include "Mesh.h" -#include "VectorHelpers.h" +#include "Scene.h" D3D9Client * D3D9Effect::gc = 0; ID3DXEffect * D3D9Effect::FX = 0; @@ -570,9 +570,9 @@ void D3D9Effect::UpdateEffectCamera(OBJHANDLE hPlanet) oapiGetRotationMatrix(hGRef, &grot); - VECTOR3 polaraxis = mul(grot, _V(0, 1, 0)); - VECTOR3 east = unit(crossp(polaraxis, cam)); - VECTOR3 north = unit(crossp(cam, east)); + VECTOR3 polaraxis = mul(grot, VECTOR3{0, 1, 0}); + VECTOR3 east = unit(cross(polaraxis, cam)); + VECTOR3 north = unit(cross(cam, east)); if (hVessel==NULL) { LogErr("hVessel = NULL in UpdateEffectCamera()"); @@ -606,7 +606,7 @@ void D3D9Effect::UpdateEffectCamera(OBJHANDLE hPlanet) FX->SetFloat(ePointScale, 0.5f*float(height)/tan(ap)); FX->SetFloat(eProxySize, cos(proxy_size)); FX->SetFloat(eInvProxySize, 1.0f/(1.0f-cos(proxy_size))); - FX->SetFloat(eGlowConst, saturate(float(dotp(cam, sun)))); + FX->SetFloat(eGlowConst, saturate(float(dot(cam, sun)))); } @@ -784,8 +784,8 @@ void D3D9Effect::RenderExhaust(const LPD3DXMATRIX pW, VECTOR3 &cdir, EXHAUSTSPEC VECTOR3 ref = (*es->lpos) - (*es->ldir)*es->lofs; const float flarescale = 7.0; - VECTOR3 sdir = crossp(cdir, edir); normalise(sdir); - VECTOR3 tdir = crossp(cdir, sdir); normalise(tdir); + VECTOR3 sdir = unit(cross(cdir, edir)); + VECTOR3 tdir = unit(cross(cdir, sdir)); float rx = (float)ref.x; float ry = (float)ref.y; float rz = (float)ref.z; @@ -988,7 +988,7 @@ void D3D9Effect::RenderArrow(OBJHANDLE hObj, const VECTOR3 *ofs, const VECTOR3 * VECTOR3 z = mul (grot, unit(*dir)) * size; VECTOR3 y = mul (grot, unit(*rot)) * size; - VECTOR3 x = mul (grot, unit(crossp(*dir, *rot))) * size; + VECTOR3 x = mul (grot, unit(cross(*dir, *rot))) * size; D3DXMatrixIdentity(&W); diff --git a/OVP/D3D9Client/D3D9Util.cpp b/OVP/D3D9Client/D3D9Util.cpp index 17f6f140b..1fff033d9 100644 --- a/OVP/D3D9Client/D3D9Util.cpp +++ b/OVP/D3D9Client/D3D9Util.cpp @@ -9,15 +9,15 @@ #define STRICT -#include "D3D9util.h" #include "AABBUtil.h" #include "D3D9Client.h" -#include "VectorHelpers.h" #include "D3D9Config.h" -#include "VPlanet.h" +#include "D3D9Util.h" #include "Mesh.h" -#include +#include "VPlanet.h" + #include +#include #include extern D3D9Client* g_client; @@ -231,7 +231,7 @@ void SurfaceLighting(D3D9Sun *light, OBJHANDLE hP, OBJHANDLE hO, float ao) float s = float(length(S)); // sun's distance float rs = float(oapiGetSize(hS)) / s; - float h = float(dotp(S,P)) / s; // sun elevation + float h = float(dot(S, P)) / s; // sun elevation float d = 0.173f; // sun elevation for dispersion float ae = 0.242f; // sun elevation for ambient float aq = 0.342f; @@ -262,9 +262,9 @@ void SurfaceLighting(D3D9Sun *light, OBJHANDLE hP, OBJHANDLE hO, float ao) lcol *= 1.0f-amb*0.5f; // reduce direct light component to avoid overexposure } - light->Color = D3DXCOLOR(lcol.x, lcol.y, lcol.z, 1.0f); - light->Ambient = D3DXCOLOR(amb, amb, amb, 1.0f); - light->Dir = D3DXVEC(S) * (-1.0f/s); + light->Color = to_FVECTOR3(lcol); + light->Ambient = FVECTOR3{amb, amb, amb}; + light->Dir = to_FVECTOR3(D3DXVEC(S) / -s); } // =========================================== // Remove unecessary spaces and tablations @@ -1375,7 +1375,7 @@ void D3D9Light::UpdateLight(const LightEmitter *_le, const class vObject *vo) // ----------------------------------------------------------------------------- if (Type != 0) { D3DXVec3TransformNormal(&Direction, ptr(D3DXVEC(le->GetDirection())), vo->MWorld()); - float angle = acos(dot(unit(Position), Direction)); + float angle = acos(dot(unit(to_FVECTOR3(Position)), to_FVECTOR3(Direction))); cone = ilerp(U * 0.5f, P * 0.5f, angle); } } diff --git a/OVP/D3D9Client/D3D9Util.h b/OVP/D3D9Client/D3D9Util.h index 0498cae89..b2c98432a 100644 --- a/OVP/D3D9Client/D3D9Util.h +++ b/OVP/D3D9Client/D3D9Util.h @@ -8,19 +8,37 @@ #ifndef __D3DUTIL_H #define __D3DUTIL_H -#include "OrbiterAPI.h" -#include "Log.h" #include "DrawAPI.h" +#include "gcCore.h" +#include "Log.h" +#include "OrbiterAPI.h" + #include #include #include -#include "gcCore.h" #define float2 FVECTOR2 #define float3 FVECTOR3 #define float4 FVECTOR4 #define float4x4 FMATRIX4 +template +constexpr auto sign(const T& x) { return x < T{0} ? T{-1} : T{1}; } + +template +constexpr auto ilerp(const T& a, const T& b, const T& x) +{ + auto v = (x - a) / (b - a); + return v > T{1} ? T{1} : v < T{0} ? T{0} : v; +} + +template +constexpr auto hermite(const T& x) { return x * x * (T{3} - T{2} * x); } + +// enable vector operators for D3DXVECTOR3 and D3DXVECTOR4 +template<> struct is_vector3 : std::true_type { }; +template<> struct is_vector4 : std::true_type { }; + #ifdef _DEBUG #ifndef _TRACE #define _TRACE { LogTrace("[TRACE] %s Line:%d %s",__FILE__,__LINE__,__FUNCTION__); } @@ -449,9 +467,9 @@ inline RECT _RECT(DWORD l, DWORD t, DWORD r, DWORD b) return rect; } -inline VECTOR3 _V(D3DXVECTOR3 &i) +inline auto _V(D3DXVECTOR3 &i) { - return _V(double(i.x), double(i.y), double(i.z)); + return VECTOR3{double(i.x), double(i.y), double(i.z)}; } inline oapi::FVECTOR3 _FV(D3DXVECTOR3 &i) @@ -459,9 +477,9 @@ inline oapi::FVECTOR3 _FV(D3DXVECTOR3 &i) return oapi::FVECTOR3(i.x, i.y, i.z); } -inline VECTOR3 _V(D3DXVECTOR4 &i) +inline auto _V(D3DXVECTOR4 &i) { - return _V(double(i.x), double(i.y), double(i.z)); + return VECTOR3{double(i.x), double(i.y), double(i.z)}; } inline void D3DXCOLORSWAP(D3DXCOLOR *x) @@ -545,9 +563,9 @@ inline D3DXCOLOR _D3DXCOLOR(const VECTOR3 &v, float a = 1.0f) return D3DXCOLOR(float(v.x), float(v.y), float(v.z), a); } -inline VECTOR3 _VD3DX(const D3DXVECTOR3 &v) +inline auto _VD3DX(const D3DXVECTOR3 &v) { - return _V(double(v.x), double(v.y), double(v.z)); + return VECTOR3{double(v.x), double(v.y), double(v.z)}; } inline VECTOR4 _VD4DX(const D3DXVECTOR4 &v) @@ -560,6 +578,31 @@ inline float D3DVAL (double x) return (float)x; } +inline auto to_FVECTOR3(const D3DXVECTOR3 &v) { return FVECTOR3{v.x, v.y, v.z}; } +inline auto to_FVECTOR4(const D3DXVECTOR4 &v) { return FVECTOR4{v.x, v.y, v.z, v.w}; } + +inline auto to_D3DXVECTOR3(const FVECTOR3 &v) { return D3DXVECTOR3{v.x, v.y, v.z}; } +inline auto to_D3DXVECTOR4(const FVECTOR4 &v) { return D3DXVECTOR4{v.x, v.y, v.z, v.w}; } + +inline auto to_D3DXVECTOR3(const VECTOR3 &v) +{ + return D3DXVECTOR3{static_cast(v.x), static_cast(v.y), static_cast(v.z)}; +} + +inline auto to_FMATRIX4(const D3DXMATRIX &m) +{ + return FMATRIX4{ + m(0,0), m(0,1), m(0,2), m(0,3), + m(1,0), m(1,1), m(1,2), m(1,3), + m(2,0), m(2,1), m(2,2), m(2,3), + m(3,0), m(3,1), m(3,2), m(3,3), + }; +} + +inline auto to_D3DXCOLOR(const FVECTOR3 &v) { return D3DXCOLOR{v.x, v.y, v.z, 1}; } + +inline auto to_FVECTOR4(const D3DXCOLOR &c) { return FVECTOR4{c.r, c.g, c.b, c.a}; } + //char* _fgets(char* cbuf, int num, FILE* stream, bool keepOneSpace = false); int fgets2(char *buf, int cmax, FILE *file, DWORD param=0); diff --git a/OVP/D3D9Client/DebugControls.cpp b/OVP/D3D9Client/DebugControls.cpp index b487ddd38..b7c0a6569 100644 --- a/OVP/D3D9Client/DebugControls.cpp +++ b/OVP/D3D9Client/DebugControls.cpp @@ -6,17 +6,17 @@ #include "D3D9Client.h" -#include "resource.h" #include "D3D9Config.h" #include "D3D9Surface.h" #include "DebugControls.h" -#include "Commctrl.h" -#include "vObject.h" -#include "vVessel.h" -#include "vPlanet.h" -#include "Mesh.h" #include "MaterialMgr.h" -#include "VectorHelpers.h" +#include "Mesh.h" +#include "resource.h" +#include "VObject.h" +#include "VPlanet.h" +#include "VVessel.h" + +#include #include enum scale { LIN, SQRT, SQR }; diff --git a/OVP/D3D9Client/HazeMgr.cpp b/OVP/D3D9Client/HazeMgr.cpp index 2ea8594ac..63e78eaa2 100644 --- a/OVP/D3D9Client/HazeMgr.cpp +++ b/OVP/D3D9Client/HazeMgr.cpp @@ -13,13 +13,12 @@ // Implemented as transparent overlay on planetary disc // ============================================================================ -#include "HazeMgr.h" -#include "VPlanet.h" +#include "D3D9Config.h" +#include "D3D9Effect.h" #include "D3D9Surface.h" #include "D3D9Util.h" -#include "VectorHelpers.h" -#include "D3D9Effect.h" -#include "D3D9Config.h" +#include "HazeMgr.h" +#include "VPlanet.h" using namespace oapi; @@ -34,7 +33,7 @@ HazeManager::HazeManager (const D3D9Client *gclient, const vPlanet *vplanet) : D hralt = (float)(atmc->horizonalt / rad); dens0 = (float)(min (1.0, atmc->horizonalt/64e3 * *(double*)oapiGetObjectParam(obj, OBJPRM_PLANET_HAZEDENSITY))); } else { - basecol = _V(1,1,1); + basecol = {1,1,1}; hralt = 0.01f; dens0 = 1.0f; } @@ -119,7 +118,7 @@ void HazeManager::Render(LPDIRECT3DDEVICE9 pDev, D3DXMATRIX &wmat, bool dual) float dens = (float)max (1.0, 1.4 - 0.3/hralt*(cdist-1.0)); // saturate haze colour at low altitudes if (dual) dens *= (float)(0.5 + 0.5/cdist); // scale down intensity at large distances - normalise (rpos); + rpos = unit(rpos); cost = (float)rpos.y, sint = (float)sqrt (1.0-cost*cost); phi = atan2 (rpos.z, rpos.x), cosp = (float)cos(phi), sinp = (float)sin(phi); @@ -139,17 +138,17 @@ void HazeManager::Render(LPDIRECT3DDEVICE9 pDev, D3DXMATRIX &wmat, bool dual) oapiGetGlobalPos (obj, &gpos); psun = tmul (grot, -gpos); // sun in planet coords psun = mul (rrmat, psun); // sun in camera-relative horizon coords - VECTOR3 cs = psun-cpos; normalise(cs); // camera->sun - normalise (psun); + VECTOR3 cs = unit(psun - cpos); // camera->sun + psun = unit(psun); // float psunx = (float)psun.x, psuny = (float)psun.y, psunz = (float)psun.z; colofs = (dual ? 0.4 : 0.3); for (i = j = 0; i < HORIZON_NSEG; i++) { VECTOR3 hp = {Vtx[j].x = r1*CosP[i], Vtx[j].y = h1, Vtx[j].z = r1*SinP[i]}; - csun = dotp (hp, psun); - VECTOR3 cp = hp-cpos; normalise(cp); - double colsh = 0.5*(dotp (cp,cs) + 1.0); + csun = dot(hp, psun); + VECTOR3 cp = unit(hp - cpos); + double colsh = 0.5 * (dot(cp, cs) + 1.0); // compose a colourful sunset double maxred = colofs-0.18*colsh, minred = maxred-0.4; @@ -308,20 +307,20 @@ void HazeManager2::RenderSky(VECTOR3 cpos, VECTOR3 cdir, double rad, double apr) double al = asin(rad/cr); VECTOR3 ur = unit(cpos); - VECTOR3 ux = unit(crossp(cdir, ur)); - VECTOR3 uy = unit(crossp(ur, ux)); + VECTOR3 ux = unit(cross(cdir, ur)); + VECTOR3 uy = unit(cross(ur, ux)); D3DXMATRIX mWL, mL; D3DMAT_Identity(&mWL); - D3DMAT_FromAxisT(&mWL, ptr(_D3DXVECTOR3(ux)), ptr(_D3DXVECTOR3(ur)), ptr(_D3DXVECTOR3(uy))); + D3DMAT_FromAxisT(&mWL, ptr(to_D3DXVECTOR3(ux)), ptr(to_D3DXVECTOR3(ur)), ptr(to_D3DXVECTOR3(uy))); double a = 15.0*RAD; double b = (PI-asin(rad/cr))/6.0; - D3DXVECTOR3 vTileCenter = D3DXVECTOR3(float(sin(15.0*RAD)), 1.0f, float(1.0+cos(15.0*RAD))) * 0.5; - D3DXMatrixRotationAxis(&mL, ptr(_D3DXVECTOR3(ur)), float(-a*0.5)); + auto vTileCenter = D3DXVECTOR3(float(std::sin(15.0 * RAD)), 1, float(1 + std::cos(15.0 * RAD))) * 0.5f; + D3DXMatrixRotationAxis(&mL, ptr(to_D3DXVECTOR3(ur)), float(-a*0.5)); D3DXMatrixMultiply(&mWL, &mWL, &mL); - D3DXMatrixRotationAxis(&mL, ptr(_D3DXVECTOR3(ur)), float(-a)); + D3DXMatrixRotationAxis(&mL, ptr(to_D3DXVECTOR3(ur)), float(-a)); //vp->GetScatterConst()->mVP = vp->GetScene()->PushCameraFrustumLimits(hd * 0.1, hd * 5.0); @@ -401,12 +400,12 @@ void HazeManager2::RenderRing(VECTOR3 cpos, VECTOR3 cdir, double rad, double hra vp->GetScatterConst()->mVP = vp->GetScene()->PushCameraFrustumLimits(hd * 0.1, hd * 5.0); VECTOR3 ur = unit(cpos); - VECTOR3 ux = unit(crossp(cdir, ur)); - VECTOR3 uy = unit(crossp(ur, ux)); + VECTOR3 ux = unit(cross(cdir, ur)); + VECTOR3 uy = unit(cross(ur, ux)); D3DXMATRIX mW; D3DMAT_Identity(&mW); - D3DMAT_FromAxisT(&mW, ptr(_D3DXVECTOR3(ux)), ptr(_D3DXVECTOR3(ur)), ptr(_D3DXVECTOR3(uy))); + D3DMAT_FromAxisT(&mW, ptr(to_D3DXVECTOR3(ux)), ptr(to_D3DXVECTOR3(ur)), ptr(to_D3DXVECTOR3(uy))); ShaderParams sprm; memcpy_s(&sprm.mWorld, sizeof(sprm.mWorld), &mW, sizeof(mW)); diff --git a/OVP/D3D9Client/Mesh.cpp b/OVP/D3D9Client/Mesh.cpp index bf72285ea..86ebfbcf9 100644 --- a/OVP/D3D9Client/Mesh.cpp +++ b/OVP/D3D9Client/Mesh.cpp @@ -8,14 +8,14 @@ #define VISIBILITY_TOL 0.0015f -#include "Mesh.h" -#include "Log.h" -#include "Scene.h" -#include "D3D9Surface.h" #include "D3D9Catalog.h" #include "D3D9Config.h" +#include "D3D9Surface.h" +#include "D3D9Util.h" #include "DebugControls.h" -#include "VectorHelpers.h" +#include "Log.h" +#include "Mesh.h" +#include "Scene.h" #pragma warning(push) #pragma warning(disable : 4838) @@ -2716,11 +2716,11 @@ void D3D9Mesh::RenderShadowMap(const LPD3DXMATRIX pW, const LPD3DXMATRIX pVP, in D3DXMATRIX GroupMatrix, mWorldMesh; MeshShader* pShader = nullptr; - - MeshShader::vs_const.mVP = *pVP; - D3DXMatrixIdentity(MeshShader::vs_const.mW); - + MeshShader::vs_const.mVP = to_FMATRIX4(*pVP); + + D3DXMatrixIdentity((D3DXMATRIX*)&MeshShader::vs_const.mW); + if (bGlobalTF) D3DXMatrixMultiply(&mWorldMesh, &mTransform, pW); else mWorldMesh = *pW; @@ -2768,11 +2768,11 @@ void D3D9Mesh::RenderShadowMap(const LPD3DXMATRIX pW, const LPD3DXMATRIX pVP, in } if (Grp[g].bTransform) { - D3DXMatrixMultiply(MeshShader::vs_const.mW, &pGrpTF[g], pW); // Apply Animations to instance matrices + D3DXMatrixMultiply((D3DXMATRIX*)&MeshShader::vs_const.mW, &pGrpTF[g], pW); // Apply Animations to instance matrices bInit = true; } else { - if (bInit) MeshShader::vs_const.mW = mWorldMesh; + if (bInit) MeshShader::vs_const.mW = to_FMATRIX4(mWorldMesh); bInit = false; } diff --git a/OVP/D3D9Client/Particle.cpp b/OVP/D3D9Client/Particle.cpp index 6bc93d18a..29509b962 100644 --- a/OVP/D3D9Client/Particle.cpp +++ b/OVP/D3D9Client/Particle.cpp @@ -54,7 +54,7 @@ D3D9ParticleStream::D3D9ParticleStream(GraphicsClient *_gc, PARTICLESTREAMSPEC * //cam_ref = &gc->GetScene()->GetCameraGPos(); //src_ref = 0; - //src_ofs = _V(0,0,0); + //src_ofs = {0,0,0}; interval = 0.1; SetSpecs (pss ? pss : &DefaultParticleStreamSpec); @@ -622,8 +622,8 @@ void ExhaustStream::Update () ((double)rand()/(double)RAND_MAX-0.5)*dv_scale}; dv += vv; - normalise(s); - VECTOR3 vv2 = dv - s*dotp(s,dv); + s = unit(s); + VECTOR3 vv2 = dv - s * dot(s, dv); if (length(vv2)) vv2 *= 0.5*length(vv)/length(vv2); vv2 += s*(((double)rand()/(double)RAND_MAX)*dv_scale); p->vel = vv2*1.0/*2.0*/+av; @@ -704,9 +704,9 @@ void ExhaustStream::RenderGroundShadow (LPDIRECT3DDEVICE9 dev, LPDIRECT3DTEXTURE sd = unit(p->pos); // shadow projection direction VECTOR3 pv0 = p->pos - pp; // rel. particle position // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp (sd, pv0); + double fac1 = dot(sd, pv0); if (fac1 > 0.0) return; // shadow doesn't intersect planet surface - double arg = fac1*fac1 - (dotp (pv0, pv0) - R*R); + double arg = fac1 * fac1 - (dot(pv0, pv0) - R * R); if (arg <= 0.0) return; // shadow doesn't intersect with planet surface double a = -fac1 - sqrt(arg); VECTOR3 shp = sd*a; // projection point in global frame @@ -730,9 +730,9 @@ void ExhaustStream::RenderGroundShadow (LPDIRECT3DDEVICE9 dev, LPDIRECT3DTEXTURE VECTOR3 pvr = p->pos - pp; // rel. particle position // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp (sd, pvr); + double fac1 = dot(sd, pvr); if (fac1 > 0.0) break; // shadow doesn't intersect planet surface - double arg = fac1*fac1 - (dotp (pvr, pvr) - R*R); + double arg = fac1 * fac1 - (dot(pvr, pvr) - R * R); if (arg <= 0.0) break; // shadow doesn't intersect with planet surface double a = -fac1 - sqrt(arg); @@ -767,7 +767,7 @@ ReentryStream::ReentryStream (oapi::GraphicsClient *_gc, OBJHANDLE hV, PARTICLES : D3D9ParticleStream (_gc, pss) { llevel = 1.0; - Attach (hV, _V(0,0,0), _V(0,0,0), &llevel); + Attach (hV, {0,0,0}, {0,0,0}, &llevel); hPlanet = 0; } diff --git a/OVP/D3D9Client/RingMgr.cpp b/OVP/D3D9Client/RingMgr.cpp index 6aeec6cd6..19974c159 100644 --- a/OVP/D3D9Client/RingMgr.cpp +++ b/OVP/D3D9Client/RingMgr.cpp @@ -99,9 +99,9 @@ bool RingManager::Render(LPDIRECT3DDEVICE9 dev, D3DXMATRIX &mWorld, bool front) VECTOR3 gdir; oapiCameraGlobalDir(&gdir); - VECTOR3 yaxis = mul(grot, _V(0,1,0)); - VECTOR3 xaxis = unit(crossp(gdir, yaxis)); - VECTOR3 zaxis = unit(crossp(xaxis, yaxis)); + VECTOR3 yaxis = mul(grot, VECTOR3{0, 1, 0}); + VECTOR3 xaxis = unit(cross(gdir, yaxis)); + VECTOR3 zaxis = unit(cross(xaxis, yaxis)); if (!front) { xaxis = -xaxis; diff --git a/OVP/D3D9Client/RunwayLights.cpp b/OVP/D3D9Client/RunwayLights.cpp index 7689b2f1f..2f1aa8700 100644 --- a/OVP/D3D9Client/RunwayLights.cpp +++ b/OVP/D3D9Client/RunwayLights.cpp @@ -23,8 +23,8 @@ RunwayLights::RunwayLights(class vBase *_vB, const class Scene *scn) { vB = _vB; scene = scn; - end1 = _V(0, 0, 0); - end2 = _V(0, 0, 0); + end1 = {0, 0, 0}; + end2 = {0, 0, 0}; width = 50.0; td_disp = 0.0; td_disp2 = 0.0; @@ -39,13 +39,13 @@ RunwayLights::RunwayLights(class vBase *_vB, const class Scene *scn) bDisp2 = false; for (int i=0; i<12; ++i) { - PAPI_pos[i] = _V(0,0,0); + PAPI_pos[i] = {0,0,0}; PAPI_disp[i] = 0.0; PAPI_end[i] = 0; papi[i] = NULL; } for (int i=0; i<2; ++i) { - VASI[i] = _V(0,0,0); + VASI[i] = {0,0,0}; VASI_end[i] = 0; vasi[i] = NULL; } @@ -199,7 +199,7 @@ BeaconArray *RunwayLights::BuildLights(VECTOR3 _start, VECTOR3 _end, double disp VECTOR3 _space; // Vector between each light VECTOR3 _current; // Incremented in the for loop VECTOR3 _shift; - VECTOR3 _widthDir = unit(crossp(_dir, _V(0, 1, 0))); // used to calculate the edge lights + VECTOR3 _widthDir = unit(cross(_dir, VECTOR3{0, 1, 0})); // used to calculate the edge lights BeaconArrayEntry* beaconsEntry1 = new BeaconArrayEntry[numLights]; @@ -218,9 +218,9 @@ BeaconArray *RunwayLights::BuildLights(VECTOR3 _start, VECTOR3 _end, double disp centerLight.loff = 1.0f; centerLight.bright = 1.5f * brightness; centerLight.fall = 0.5; - centerLight.pos = _V(0,0,0); + centerLight.pos = {0,0,0}; centerLight.color = 0; - centerLight.dir = _dir*cos(upAngle*RAD) + _V(0, 1, 0)*sin(upAngle*RAD); + centerLight.dir = _dir * std::cos(upAngle * RAD) + VECTOR3{0, 1, 0} * std::sin(upAngle * RAD); endLight = centerLight; edgeLight = centerLight; @@ -510,7 +510,7 @@ BeaconArray *RunwayLights::BuildLights(VECTOR3 _start, VECTOR3 _end, double disp OBJHANDLE hPlanet = oapiGetBasePlanet(hObj); // double size = oapiGetSize(hPlanet); - for (int k=0;kRwyBrightness); papiLight.fall = 0.5; - papiLight.pos = _V(0,0,0); + papiLight.pos = {0,0,0}; papiLight.color = 0; - papiLight.dir = dir*cos(upAngle*RAD) + _V(0, 1, 0)*sin(upAngle*RAD); + papiLight.dir = dir * std::cos(upAngle * RAD) + VECTOR3{0, 1, 0} * std::sin(upAngle * RAD); BeaconArrayEntry entryPAPI[4]; for(int j=0; j<4; j++) { entryPAPI[j] = papiLight; - entryPAPI[j].dir = _V(-entryPAPI[j].dir.x, entryPAPI[j].dir.y, -entryPAPI[j].dir.z); + entryPAPI[j].dir = {-entryPAPI[j].dir.x, entryPAPI[j].dir.y, -entryPAPI[j].dir.z}; entryPAPI[j].pos = start + dir*PAPI_pos[i].z + widthDir*disp + widthDir*j*papi_separation - widthDir*papi_separation*1.5; } @@ -569,8 +569,7 @@ BeaconArray *RunwayLights::BuildVASI(VECTOR3 _start, VECTOR3 _end, DWORD idx) // Helping vectors VECTOR3 _direction = _end - _start; // Vector of the runway - VECTOR3 _dir = _direction; // Normalized direction - normalise(_dir); + VECTOR3 _dir = unit(_direction); // Normalized direction VECTOR3 _td_disp = _dir * td_disp; // Touch zone displacement vector _start += _td_disp; @@ -583,8 +582,7 @@ BeaconArray *RunwayLights::BuildVASI(VECTOR3 _start, VECTOR3 _end, DWORD idx) // Main lights vectors VECTOR3 _current; // Incremented in the for loop - VECTOR3 _widthDir = crossp(_direction, _V(0, 1, 0)); // used to calculate the edge lights - normalise(_widthDir); + VECTOR3 _widthDir = unit(cross(_direction, VECTOR3{0, 1, 0})); // used to calculate the edge lights BeaconArrayEntry* beaconsEntry1 = new BeaconArrayEntry[30]; @@ -601,9 +599,9 @@ BeaconArray *RunwayLights::BuildVASI(VECTOR3 _start, VECTOR3 _end, DWORD idx) vasiLight.loff = 1.0f; vasiLight.bright = 3.0f * float(Config->RwyBrightness); vasiLight.fall = 0.1f; - vasiLight.pos = _V(0,0,0); + vasiLight.pos = {0,0,0}; vasiLight.color = 0; - vasiLight.dir = _dir*cos(upAngle*RAD) + _V(0, 1, 0)*sin(upAngle*RAD); + vasiLight.dir = _dir * std::cos(upAngle * RAD) + VECTOR3{0, 1, 0} * std::sin(upAngle * RAD); _current = _start + _dir * VASI[e].z + _widthDir * (width/2.0 + 30.0); _current.y = 0; @@ -612,7 +610,7 @@ BeaconArray *RunwayLights::BuildVASI(VECTOR3 _start, VECTOR3 _end, DWORD idx) beaconsEntry1[i] = vasiLight; beaconsEntry1[i].color = red; beaconsEntry1[i].size = 1.0f * lightSize; - beaconsEntry1[i].pos = _current + _widthDir * 2.0 * float(k) + _V(0,1,0); + beaconsEntry1[i].pos = _current + _widthDir * 2.0 * float(k) + VECTOR3{0, 1, 0}; } _current -= _dir * VASI[e].y; @@ -620,7 +618,7 @@ BeaconArray *RunwayLights::BuildVASI(VECTOR3 _start, VECTOR3 _end, DWORD idx) for (k=0;k<5;k++, i++) { beaconsEntry1[i] = vasiLight; beaconsEntry1[i].color = white; - beaconsEntry1[i].pos = _current + _widthDir * 2.0 * float(k) + _V(0,1,0) + _V(0,1,0)*(sin(VASI[e].x*RAD)*VASI[e].y); + beaconsEntry1[i].pos = _current + _widthDir * 2.0 * float(k) + VECTOR3{0, 1, 0} + VECTOR3{0, 1, 0} * (std::sin(VASI[e].x * RAD) * VASI[e].y); } // Post process lights ------------------------------------------ @@ -629,7 +627,7 @@ BeaconArray *RunwayLights::BuildVASI(VECTOR3 _start, VECTOR3 _end, DWORD idx) double size = oapiGetSize(hPlanet); for (int k=0;k #include @@ -727,13 +727,13 @@ VECTOR3 Scene::SkyColour () if (cdist < atmp->radlimit) { ATMPARAM prm; oapiGetPlanetAtmParams (hProxy, cdist, &prm); - normalise (rp); - double coss = dotp (pc, rp) / -cdist; + rp = unit(rp); + double coss = dot(pc, rp) / -cdist; double intens = min (1.0,(1.0839*coss+0.4581)) * sqrt (prm.rho/atmp->rho0); // => intensity=0 at sun zenith distance 115? // intensity=1 at sun zenith distance 60? if (intens > 0.0) - col += _V(atmp->color0.x*intens, atmp->color0.y*intens, atmp->color0.z*intens); + col += {atmp->color0.x*intens, atmp->color0.y*intens, atmp->color0.z*intens}; } for (int i=0;i<3;i++) if (col.data[i] > 1.0) col.data[i] = 1.0; } @@ -878,10 +878,10 @@ void Scene::GetLVLH(vVessel *vV, D3DXVECTOR3 *up, D3DXVECTOR3 *nr, D3DXVECTOR3 * OBJHANDLE hRef = hV->GetGravityRef(); oapiGetRotationMatrix(hRef, &grot); hV->GetRelativePos(hRef, rpos); - VECTOR3 axis = mul(grot, _V(0, 1, 0)); - normalise(rpos); + VECTOR3 axis = mul(grot, VECTOR3{0, 1, 0}); + rpos = unit(rpos); *up = D3DXVEC(rpos); - *fw = D3DXVEC(unit(crossp(axis, rpos))); + *fw = D3DXVEC(unit(cross(axis, rpos))); D3DXVec3Cross(nr, up, fw); D3DXVec3Normalize(nr, nr); } @@ -905,7 +905,7 @@ float Scene::ComputeNearClipPlane() VECTOR3 pos; oapiGetGlobalPos(hObj,&pos); double g = atan(Camera.apsq); - double t = dotp(unit(Camera.pos-pos), unit(Camera.dir)); + double t = dot(unit(Camera.pos-pos), unit(Camera.dir)); if (t<-1.0) t=1.0; if (t>1.0) t=1.0f; double a = PI - acos(t); double R = oapiGetSize(hObj) + hVes->GetSurfaceElevation(); @@ -1169,7 +1169,7 @@ void Scene::ComputeLocalLightsVisibility() { if (Lights[i].cone > 0.0f) { LLCBuf[nGlares].index = float(nGlares); - LLCBuf[nGlares].pos = Lights[i].Position; + LLCBuf[nGlares].pos = to_FVECTOR3(Lights[i].Position); LLCBuf[nGlares].cone = Lights[i].cone; Lights[i].GPUId = nGlares; nGlares++; @@ -1191,7 +1191,7 @@ void Scene::ComputeLocalLightsVisibility() psgBuffer[GBUF_DEPTH]->GetDesc(&desc); ComputeData.vSrc = FVECTOR4((float)desc.Width, (float)desc.Height, 1.0f / (float)desc.Width, 1.0f / (float)desc.Height); - ComputeData.vDir = Camera.z; + ComputeData.vDir = to_FVECTOR3(Camera.z); ComputeData.mSVP = Camera.mProjView; // Must setup render target before calling Setup() @@ -1514,7 +1514,7 @@ void Scene::RenderMainScene() SmapRenderList.clear(); SmapRenderList.push_back(vFocus); - D3DXVECTOR3 ld = sunLight.Dir; + auto ld = to_D3DXVECTOR3(sunLight.Dir); D3DXVECTOR3 pos = vFocus->GetBoundingSpherePosDX(); float rad = vFocus->GetBoundingSphereRadius(); float frad = rad; @@ -1643,7 +1643,7 @@ void Scene::RenderMainScene() const std::vector& ls = list[n].marker; VECTOR3 sp; for (int j = 0; j < ls.size(); j++) { - if (dotp(ls[j].pos, cpos - ls[j].pos) >= 0.0) { // surface point visible? + if (dot(ls[j].pos, cpos - ls[j].pos) >= 0.0) { // surface point visible? sp = mul(prot, ls[j].pos) + ppos; RenderObjectMarker(pSketch, sp, ls[j].label[0], ls[j].label[1], list[n].shape, size); } @@ -1675,7 +1675,7 @@ void Scene::RenderMainScene() double apprad = 8000e3 / (length(cpos - bpos) * tan(GetCameraAperture())); - if (dotp(bpos, cpos - bpos) >= 0.0 && apprad > LABEL_DISTLIMIT) { // surface point visible? + if (dot(bpos, cpos - bpos) >= 0.0 && apprad > LABEL_DISTLIMIT) { // surface point visible? char name[64]; oapiGetObjectName(hBase, name, 63); VECTOR3 sp = mul(prot, bpos) + ppos; RenderObjectMarker(pSketch, sp, std::string(name), std::string(), 0, size); @@ -1779,7 +1779,7 @@ void Scene::RenderMainScene() // if (Config->ShadowMapMode >= 1) { - D3DXVECTOR3 ld = sunLight.Dir; + auto ld = to_D3DXVECTOR3(sunLight.Dir); D3DXVECTOR3 pos = vFocus->GetBoundingSpherePosDX(); float rad = vFocus->GetBoundingSphereRadius(); @@ -1825,7 +1825,7 @@ void Scene::RenderMainScene() while (!Intersect.empty()) { - D3DXVECTOR3 ld = sunLight.Dir; + auto ld = to_D3DXVECTOR3(sunLight.Dir); D3DXVECTOR3 pos = Intersect.front()->GetBoundingSpherePosDX(); float rad = Intersect.front()->GetBoundingSphereRadius(); @@ -2377,7 +2377,7 @@ D3DXCOLOR Scene::GetSunDiffColor() float pwr = 1.0f; - if (hP == hS) return GetSun()->Color; + if (hP == hS) return to_D3DXCOLOR(GetSun()->Color); double r = length(P); double pres = 1000.0; @@ -2394,7 +2394,7 @@ D3DXCOLOR Scene::GetSunDiffColor() float k = float(sqrt(r*r - size*size)); // Horizon distance float alt = float(r - size); float rs = float(oapiGetSize(hS) / s); - float ac = float(-dotp(S, P) / (r*s)); // sun elevation + float ac = float(-dot(S, P) / (r * s)); // sun elevation // Avoid some fault conditions if (alt<0) alt = 0, k = 1e3, size = r; @@ -3040,8 +3040,7 @@ bool Scene::WorldToScreenSpace2(const VECTOR3& wpos, oapi::FVECTOR2* pt, D3DXMAT // void Scene::RenderObjectMarker(oapi::Sketchpad *pSkp, const VECTOR3 &gpos, const std::string& label1, const std::string& label2, int mode, int scale) { - VECTOR3 dp (gpos - GetCameraGPos()); - normalise (dp); + VECTOR3 dp = unit(gpos - GetCameraGPos()); m_celSphere->RenderMarker(pSkp, dp, label1, label2, mode, scale); } @@ -3173,7 +3172,7 @@ FMATRIX4 Scene::PushCameraFrustumLimits(float nearlimit, float farlimit) FRUSTUM fr = { Camera.nearplane, Camera.farplane }; FrustumStack.push(fr); SetCameraFrustumLimits(nearlimit, farlimit); - return FMATRIX4(GetProjectionViewMatrix()); + return to_FMATRIX4(*GetProjectionViewMatrix()); } // =========================================================================================== @@ -3182,7 +3181,7 @@ FMATRIX4 Scene::PopCameraFrustumLimits() { SetCameraFrustumLimits(FrustumStack.top().znear, FrustumStack.top().zfar); FrustumStack.pop(); - return FMATRIX4(GetProjectionViewMatrix()); + return to_FMATRIX4(*GetProjectionViewMatrix()); } // =========================================================================================== @@ -3375,7 +3374,7 @@ void Scene::UpdateCameraFromOrbiter(DWORD dwPass) else { // Camera target doesn't exist. (Should not happen) oapiCameraGlobalPos(&Camera.pos); - Camera.relpos = _V(0,0,0); + Camera.relpos = {0,0,0}; } oapiCameraGlobalDir(&Camera.dir); @@ -3669,7 +3668,7 @@ void Scene::RenderGlares() Const.GPUId = (float(GPUId) + 0.5f) / desc.Width; Const.Pos = FVECTOR4(pt.x, pt.y, size, size); Const.Alpha = Lights[i].cone; - Const.Color = Lights[i].Diffuse; + Const.Color = to_FVECTOR4(Lights[i].Diffuse); Const.Blend = 1.0f; pRenderGlares->SetVSConstants("Const", &Const, sizeof(Const)); pRenderGlares->SetPSConstants("Const", &Const, sizeof(Const)); diff --git a/OVP/D3D9Client/Spherepatch.cpp b/OVP/D3D9Client/Spherepatch.cpp index 20186ba27..990b7b990 100644 --- a/OVP/D3D9Client/Spherepatch.cpp +++ b/OVP/D3D9Client/Spherepatch.cpp @@ -265,9 +265,9 @@ void CreateSpherePatch (LPDIRECT3DDEVICE9 pDev, VBMESH &mesh, int nlng, int nlat double clng0 = cos(minlng), slng0 = sin(minlng); double clat1 = cos(maxlat), slat1 = sin(maxlat); double clng1 = cos(maxlng), slng1 = sin(maxlng); - VECTOR3 ex = {clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}; normalise(ex); - VECTOR3 ey = {0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}; normalise(ey); - VECTOR3 ez = crossp (ey, ex); + auto ex = unit(VECTOR3{clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}); + auto ey = unit(VECTOR3{0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}); + auto ez = cross(ey, ex); MATRIX3 R = {ex.x, ex.y, ex.z, ey.x, ey.y, ey.z, ez.x, ez.y, ez.z}; VECTOR3 pref = {0.5*(clat0*clng1 + clat0*clng0), slat0, 0.5*(clat0*slng1 + clat0*slng0)}; // origin VECTOR3 tpmin, tpmax; @@ -285,7 +285,7 @@ void CreateSpherePatch (LPDIRECT3DDEVICE9 pDev, VBMESH &mesh, int nlng, int nlat for (j = 0; j <= nseg; j++) { lng = (nseg ? minlng + (maxlng-minlng) * (double)j/(double)nseg : 0.0); slng = sin(lng), clng = cos(lng); - pos = _V(clat*clng, slat, clat*slng); + pos = {clat*clng, slat, clat*slng}; tpos = mul (R, pos-pref); if (!n) { tpmin = tpos; @@ -360,14 +360,14 @@ void CreateSpherePatch (LPDIRECT3DDEVICE9 pDev, VBMESH &mesh, int nlng, int nlat } // transform bounding box back to patch coordinates - mesh.Box[0] = _V(tmul (R, _V(tpmin.x, tpmin.y, tpmin.z)) + pref); - mesh.Box[1] = _V(tmul (R, _V(tpmax.x, tpmin.y, tpmin.z)) + pref); - mesh.Box[2] = _V(tmul (R, _V(tpmin.x, tpmax.y, tpmin.z)) + pref); - mesh.Box[3] = _V(tmul (R, _V(tpmax.x, tpmax.y, tpmin.z)) + pref); - mesh.Box[4] = _V(tmul (R, _V(tpmin.x, tpmin.y, tpmax.z)) + pref); - mesh.Box[5] = _V(tmul (R, _V(tpmax.x, tpmin.y, tpmax.z)) + pref); - mesh.Box[6] = _V(tmul (R, _V(tpmin.x, tpmax.y, tpmax.z)) + pref); - mesh.Box[7] = _V(tmul (R, _V(tpmax.x, tpmax.y, tpmax.z)) + pref); + mesh.Box[0] = _V(tmul (R, {tpmin.x, tpmin.y, tpmin.z}) + pref); + mesh.Box[1] = _V(tmul (R, {tpmax.x, tpmin.y, tpmin.z}) + pref); + mesh.Box[2] = _V(tmul (R, {tpmin.x, tpmax.y, tpmin.z}) + pref); + mesh.Box[3] = _V(tmul (R, {tpmax.x, tpmax.y, tpmin.z}) + pref); + mesh.Box[4] = _V(tmul (R, {tpmin.x, tpmin.y, tpmax.z}) + pref); + mesh.Box[5] = _V(tmul (R, {tpmax.x, tpmin.y, tpmax.z}) + pref); + mesh.Box[6] = _V(tmul (R, {tpmin.x, tpmax.y, tpmax.z}) + pref); + mesh.Box[7] = _V(tmul (R, {tpmax.x, tpmax.y, tpmax.z}) + pref); } diff --git a/OVP/D3D9Client/SurfMgr.cpp b/OVP/D3D9Client/SurfMgr.cpp index 395031ba1..a39539971 100644 --- a/OVP/D3D9Client/SurfMgr.cpp +++ b/OVP/D3D9Client/SurfMgr.cpp @@ -36,7 +36,7 @@ SurfaceManager::SurfaceManager (D3D9Client *gclient, const vPlanet *vplanet) maxbaselvl = min(8, maxlvl); - pcdir = _V(1,0,0); + pcdir = {1,0,0}; lightfac = *(double*)gc->GetConfigParam (CFGPRM_SURFACELIGHTBRT); spec_base = 0.95f; atmc = oapiGetPlanetAtmConstants (obj); diff --git a/OVP/D3D9Client/Surfmgr2.cpp b/OVP/D3D9Client/Surfmgr2.cpp index 5056100ac..4d7733509 100644 --- a/OVP/D3D9Client/Surfmgr2.cpp +++ b/OVP/D3D9Client/Surfmgr2.cpp @@ -12,16 +12,16 @@ // LOD (level-of-detail) algorithm for surface patch resolution. // ============================================================== -#include "Surfmgr2.h" -#include "Tilemgr2.h" #include "Cloudmgr2.h" #include "D3D9Catalog.h" #include "D3D9Config.h" -#include "vVessel.h" -#include "VectorHelpers.h" +#include "D3D9Surface.h" +#include "D3D9Util.h" #include "DebugControls.h" #include "gcCore.h" -#include "D3D9Surface.h" +#include "Surfmgr2.h" +#include "Tilemgr2.h" +#include "VVessel.h" // ======================================================================= extern void FilterElevationGraphics(OBJHANDLE hPlanet, int lvl, int ilat, int ilng, float *elev); @@ -797,7 +797,7 @@ void SurfTile::Render () bool render_shadows = (mgr->GetPlanet()->CloudMgr2() != NULL) && mgr->GetClient()->GetConfigParam(CFGPRM_CLOUDSHADOWS) && pShader->bCloudShd; if (ltex) { - sdist = acos(dotp(mgr->prm.sdir, cnt)); + sdist = std::acos(dot(mgr->prm.sdir, cnt)); rad = rad0 / (double)(2 << lvl); // tile radius has_specular = (ltex != NULL) && sdist < (1.75 + rad); has_lights = (render_lights && ltex && sdist > 1.35); @@ -973,7 +973,7 @@ void SurfTile::Render () sp->vTexOff = GetTexRangeDX(&texrange); sp->vMicroOff = GetTexRangeDX(µrange); - sp->mWorld = mWorld; + sp->mWorld = to_FMATRIX4(mWorld); sp->fTgtScale = tgtscale; if (has_lights) sp->fBeta = float(mgr->Cprm().lightfac); @@ -1003,7 +1003,7 @@ void SurfTile::Render () if (sqrt(D3DXVec3Dot(&bc, &bc) - x * x) < (shd->rad + mesh->bsRad)) { float s = float(shd->size); float sr = 2.0f * shd->rad / s; - sp->mLVP = shd->mViewProj; + sp->mLVP = to_FMATRIX4(shd->mViewProj); sp->vSHD = FVECTOR4(sr, 1.0f / s, 0.0f, 1.0f / shd->depth); fc->bShadows = true; } @@ -1066,11 +1066,11 @@ void SurfTile::Render () for (int i = 0; i < nMeshLights; i++) { auto pL = pLights[LightList[i].idx]; - Locals.attenuation[i] = pL.Attenuation; + Locals.attenuation[i] = to_FVECTOR3(pL.Attenuation); Locals.diffuse[i] = FVECTOR4(pL.Diffuse).rgb; - Locals.direction[i] = pL.Direction; - Locals.param[i] = pL.Param; - Locals.position[i] = pL.Position; + Locals.direction[i] = to_FVECTOR3(pL.Direction); + Locals.param[i] = to_FVECTOR4(pL.Param); + Locals.position[i] = to_FVECTOR3(pL.Position); Spots[i] = (pL.Type == 1); } diff --git a/OVP/D3D9Client/TileLabel.cpp b/OVP/D3D9Client/TileLabel.cpp index bd9f85976..1fc88220b 100644 --- a/OVP/D3D9Client/TileLabel.cpp +++ b/OVP/D3D9Client/TileLabel.cpp @@ -284,7 +284,7 @@ void TileLabel::Render (D3D9Pad *skp, oapi::Font **labelfont, int *fontidx) for (i = 0; i < nrenderlabel; ++i) { VECTOR3 camlabelpos = campos-renderlabel[i]->pos; - if (dotp (renderlabel[i]->pos, camlabelpos) >= 0.0) { + if (dot(renderlabel[i]->pos, camlabelpos) >= 0.0) { double fontscale = 1e4/length(camlabelpos)*(13-min(tile->lvl,12)*1); int idx = max(0, min(3, (int)fontscale)); if (idx != *fontidx) { diff --git a/OVP/D3D9Client/TileMgr.cpp b/OVP/D3D9Client/TileMgr.cpp index 32d09b5f5..b94123ebb 100644 --- a/OVP/D3D9Client/TileMgr.cpp +++ b/OVP/D3D9Client/TileMgr.cpp @@ -482,9 +482,8 @@ void TileManager::Render(LPDIRECT3DDEVICE9 dev, D3DXMATRIX &wmat, double scale, D3DMAT_Copy (&RenderParam.wmat, &wmat); D3DMAT_Copy (&RenderParam.wmat_tmp, &wmat); D3DMAT_MatrixInvert (&imat, &wmat); - RenderParam.cdir = _V(imat._41, imat._42, imat._43); // camera position in local coordinates (units of planet radii) - RenderParam.cpos = vp->PosFromCamera() * scale; - normalise (RenderParam.cdir); // camera direction + RenderParam.cdir = unit(VECTOR3{imat._41, imat._42, imat._43}); // camera direction + RenderParam.cpos = vp->PosFromCamera() * scale; // camera position in local coordinates (units of planet radii) RenderParam.bfog = bfog; oapiGetRotationMatrix (obj, &RenderParam.grot); @@ -495,12 +494,11 @@ void TileManager::Render(LPDIRECT3DDEVICE9 dev, D3DXMATRIX &wmat, double scale, RenderParam.objsize = oapiGetSize (obj); RenderParam.cdist = vp->CamDist() / vp->GetSize(); // camera distance in units of planet radius RenderParam.viewap = (viewap ? viewap : acos (1.0/max (1.0, RenderParam.cdist))); - RenderParam.sdir = tmul (RenderParam.grot, -gpos); + RenderParam.sdir = unit(tmul(RenderParam.grot, -gpos)); // sun direction in planet frame RenderParam.horzdist = sqrt(RenderParam.cdist*RenderParam.cdist-1.0) * RenderParam.objsize; - normalise (RenderParam.sdir); // sun direction in planet frame // limit resolution for fast camera movements - double limitstep, cstep = acos (dotp (RenderParam.cdir, pcdir)); + double limitstep, cstep = std::acos(dot(RenderParam.cdir, pcdir)); int maxlevel = SURF_MAX_PATCHLEVEL; static double limitstep0 = 5.12 * pow(2.0, -(double)SURF_MAX_PATCHLEVEL); for (limitstep = limitstep0; cstep > limitstep && maxlevel > 5; limitstep *= 2.0) @@ -567,7 +565,7 @@ void TileManager::ProcessTile (int lvl, int hemisp, int ilat, int nlat, int ilng static const double rad0 = sqrt(2.0)*PI05*0.5; VECTOR3 cnt = TileCentre (hemisp, ilat, nlat, ilng, nlng); double rad = rad0/(double)nlat; - double x = dotp (RenderParam.cdir, cnt); + double x = dot(RenderParam.cdir, cnt); double adist = acos(x) - rad; if (adist >= RenderParam.viewap) { @@ -670,7 +668,7 @@ void TileManager::ProcessTile (int lvl, int hemisp, int ilat, int nlat, int ilng // actually render the tile at this level --------------------------------------- // - double sdist = acos (dotp (RenderParam.sdir, cnt)); + double sdist = std::acos(dot(RenderParam.sdir, cnt)); if (bCoarseTex) { //if (sdist > PI05+rad && bkp_flag & 2) bkp_flag &= 0xFD; @@ -690,8 +688,8 @@ VECTOR3 TileManager::TileCentre (int hemisp, int ilat, int nlat, int ilng, int n { double cntlat = PI*0.5 * ((double)ilat+0.5)/(double)nlat, slat = sin(cntlat), clat = cos(cntlat); double cntlng = PI*2.0 * ((double)ilng+0.5)/(double)nlng + PI, slng = sin(cntlng), clng = cos(cntlng); - if (hemisp) return _V(clat*clng, -slat, -clat*slng); - else return _V(clat*clng, slat, clat*slng); + if (hemisp) return {clat*clng, -slat, -clat*slng}; + else return {clat*clng, slat, clat*slng}; } // ======================================================================= @@ -761,7 +759,7 @@ bool TileManager::SpecularColour (D3DCOLORVALUE *col) return false; } else { double fac = 0.7; // needs thought ... - double cosa = dotp (RenderParam.cdir, RenderParam.sdir); + double cosa = dot(RenderParam.cdir, RenderParam.sdir); double alpha = 0.5*acos(cosa); // sun reflection angle double scale = sin(alpha)*fac; col->r = (float)max(0.0, spec_base - scale*atmc->color0.x); diff --git a/OVP/D3D9Client/Tilemgr2.cpp b/OVP/D3D9Client/Tilemgr2.cpp index 6818d7ddd..4ec099e35 100644 --- a/OVP/D3D9Client/Tilemgr2.cpp +++ b/OVP/D3D9Client/Tilemgr2.cpp @@ -389,7 +389,7 @@ VECTOR3 Tile::Centre () const int nlng = 2 << lvl; double cntlat = PI05 - PI * ((double)ilat+0.5)/(double)nlat, slat = sin(cntlat), clat = cos(cntlat); double cntlng = PI2 * ((double)ilng+0.5)/(double)nlng + PI, slng = sin(cntlng), clng = cos(cntlng); - return _V(clat*clng, slat, clat*slng); + return {clat*clng, slat, clat*slng}; } @@ -451,9 +451,9 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, float *elev, double double clng0 = cos(minlng), slng0 = sin(minlng); double clat1 = cos(maxlat), slat1 = sin(maxlat); double clng1 = cos(maxlng), slng1 = sin(maxlng); - VECTOR3 ex = {clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}; normalise (ex); - VECTOR3 ey = {0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}; normalise (ey); - VECTOR3 ez = crossp (ey, ex); + auto ex = unit(VECTOR3{clat0*clng1 - clat0*clng0, 0, clat0*slng1 - clat0*slng0}); + auto ey = unit(VECTOR3{0.5*(clng0+clng1)*(clat1-clat0), slat1-slat0, 0.5*(slng0+slng1)*(clat1-clat0)}); + auto ez = cross(ey, ex); MATRIX3 R = {ex.x, ex.y, ex.z, ey.x, ey.y, ey.z, ez.x, ez.y, ez.z}; VECTOR3 pref = {radius*clat0*0.5*(clng1+clng0), radius*slat0, radius*clat0*0.5*(slng1+slng0)}; // origin VECTOR3 tpmin, tpmax; @@ -485,7 +485,7 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, float *elev, double if (elev) e = elev[(i+1)*TILE_ELEVSTRIDE + j+1] * float(elev_scale); eradius += double(e); - nml = _V(clat*clng, slat, clat*slng); + nml = {clat*clng, slat, clat*slng}; pos = nml*eradius; tpos = mul (R, pos-pref); if (!n) { @@ -587,8 +587,7 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, float *elev, double // This version avoids the normalisation of the 4 intermediate face normals // It's faster and doesn't seem to make much difference - VECTOR3 nml = { 2.0*dydz, dz*elev_scale*(elev[en - TILE_ELEVSTRIDE] - elev[en + TILE_ELEVSTRIDE]), dy*elev_scale*(elev[en - 1] - elev[en + 1]) }; - normalise (nml); + auto nml = unit(VECTOR3{ 2.0*dydz, dz*elev_scale*(elev[en - TILE_ELEVSTRIDE] - elev[en + TILE_ELEVSTRIDE]), dy*elev_scale*(elev[en - 1] - elev[en + 1]) }); // rotate into place nx1 = nml.x*clat - nml.y*slat; ny1 = nml.x*slat + nml.y*clat; @@ -630,14 +629,14 @@ VBMESH *Tile::CreateMesh_quadpatch (int grdlat, int grdlng, float *elev, double pref.x -= dx; pref.y -= dy; - mesh->Box[0] = _V(tmul (R, _V(tpmin.x, tpmin.y, tpmin.z)) + pref); - mesh->Box[1] = _V(tmul (R, _V(tpmax.x, tpmin.y, tpmin.z)) + pref); - mesh->Box[2] = _V(tmul (R, _V(tpmin.x, tpmax.y, tpmin.z)) + pref); - mesh->Box[3] = _V(tmul (R, _V(tpmax.x, tpmax.y, tpmin.z)) + pref); - mesh->Box[4] = _V(tmul (R, _V(tpmin.x, tpmin.y, tpmax.z)) + pref); - mesh->Box[5] = _V(tmul (R, _V(tpmax.x, tpmin.y, tpmax.z)) + pref); - mesh->Box[6] = _V(tmul (R, _V(tpmin.x, tpmax.y, tpmax.z)) + pref); - mesh->Box[7] = _V(tmul (R, _V(tpmax.x, tpmax.y, tpmax.z)) + pref); + mesh->Box[0] = _V(tmul(R, {tpmin.x, tpmin.y, tpmin.z}) + pref); + mesh->Box[1] = _V(tmul(R, {tpmax.x, tpmin.y, tpmin.z}) + pref); + mesh->Box[2] = _V(tmul(R, {tpmin.x, tpmax.y, tpmin.z}) + pref); + mesh->Box[3] = _V(tmul(R, {tpmax.x, tpmax.y, tpmin.z}) + pref); + mesh->Box[4] = _V(tmul(R, {tpmin.x, tpmin.y, tpmax.z}) + pref); + mesh->Box[5] = _V(tmul(R, {tpmax.x, tpmin.y, tpmax.z}) + pref); + mesh->Box[6] = _V(tmul(R, {tpmin.x, tpmax.y, tpmax.z}) + pref); + mesh->Box[7] = _V(tmul(R, {tpmax.x, tpmax.y, tpmax.z}) + pref); mesh->ComputeSphere(); mesh->MapVertices(TileManager2Base::pDev); @@ -684,7 +683,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, float *elev, double globelev) slng = sin(lng), clng = cos(lng); eradius = radius + globelev; // radius including node elevation if (elev) eradius += (double)elev[(grd+1-y)*TILE_ELEVSTRIDE + x+1]; - nml = _V(slat*clng, clat, slat*slng); + nml = {slat*clng, clat, slat*slng}; pos = nml*eradius; vtx->x = D3DVAL(pos.x); vtx->nx = D3DVAL(nml.x); vtx->y = D3DVAL(pos.y); vtx->ny = D3DVAL(nml.y); @@ -717,7 +716,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, float *elev, double globelev) for (x = 0; x < x2; x++) mn += (double)elev[TILE_ELEVSTRIDE*(grd+1) + x+1]; eradius += mn/x2; } - nml = _V(0,1,0); + nml = {0,1,0}; pos = nml*eradius; vtx->x = D3DVAL(pos.x); vtx->nx = D3DVAL(nml.x); vtx->y = D3DVAL(pos.y); vtx->ny = D3DVAL(nml.y); @@ -735,7 +734,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, float *elev, double globelev) for (x = 0; x < x2; x++) mn += (double)elev[TILE_ELEVSTRIDE + x+1]; eradius += mn/x2; } - nml = _V(0,-1,0); + nml = {0,-1,0}; pos = nml*eradius; vtx->x = D3DVAL(pos.x); vtx->nx = D3DVAL(nml.x); vtx->y = D3DVAL(pos.y); vtx->ny = D3DVAL(nml.y); @@ -783,8 +782,7 @@ VBMESH *Tile::CreateMesh_hemisphere (int grd, float *elev, double globelev) if (!ilng) lng -= PI; slng = sin(lng), clng = cos(lng); en = (grd+1-y)*TILE_ELEVSTRIDE + x+1; - VECTOR3 nml = {2.0*dydz, dz*(elev[en-TILE_ELEVSTRIDE]-elev[en+TILE_ELEVSTRIDE]), dy*(elev[en-1]-elev[en+1])}; - normalise(nml); + auto nml = unit(VECTOR3{2.0*dydz, dz*(elev[en-TILE_ELEVSTRIDE]-elev[en+TILE_ELEVSTRIDE]), dy*(elev[en-1]-elev[en+1])}); // rotate into place nx1 = nml.x*clat - nml.y*slat; ny1 = nml.x*slat + nml.y*clat; @@ -1190,9 +1188,8 @@ void TileManager2Base::SetRenderPrm (MATRIX4 &dwmat, double prerot, bool use_zbu prm.cdir = tmul (prm.grot, -prm.cpos); // camera's direction in planet frame double cdist = length(prm.cdir); prm.cdist = cdist / obj_size; // camera's distance in units of planet radius - normalise (prm.cdir); - prm.sdir = tmul (prm.grot, -obj_pos); // sun's direction in planet frame - normalise (prm.sdir); + prm.cdir = unit(prm.cdir); + prm.sdir = unit(tmul(prm.grot, -obj_pos)); // sun's direction in planet frame // Add 5km threshold to allow slight camera movement with out causing surface tiles to unload prm.viewap = acos (1.0/(max ((cdist+5e3) / obj_size, 1.0+minalt))); prm.scale = 1.0; diff --git a/OVP/D3D9Client/Tilemgr2_imp.hpp b/OVP/D3D9Client/Tilemgr2_imp.hpp index 4ed3e2b97..3bcf7388f 100644 --- a/OVP/D3D9Client/Tilemgr2_imp.hpp +++ b/OVP/D3D9Client/Tilemgr2_imp.hpp @@ -120,7 +120,7 @@ void TileManager2Base::ProcessNode (QuadTreeNode *node) VECTOR3 &cnt = tile->cnt; // tile centre in unit planet frame static const double rad0 = sqrt(2.0)*PI05; double rad = rad0/(double)nlat; - double alpha = acos (dotp (prm.cdir, cnt)); // angle between tile centre and camera from planet centre + double alpha = std::acos(dot(prm.cdir, cnt)); // angle between tile centre and camera from planet centre double adist = alpha - rad; // angle between closest tile corner and camera if (adist >= prm.viewap) { if (lvl == 0) diff --git a/OVP/D3D9Client/VBase.cpp b/OVP/D3D9Client/VBase.cpp index a748e7a12..7a97e6990 100644 --- a/OVP/D3D9Client/VBase.cpp +++ b/OVP/D3D9Client/VBase.cpp @@ -361,7 +361,7 @@ bool vBase::Update (bool bMainScene) if (fabs(simt-Tchk)>1.0) { VECTOR3 pos, sdir; MATRIX3 rot; - oapiGetGlobalPos (hObj, &pos); normalise(pos); + oapiGetGlobalPos (hObj, &pos); pos = unit(pos); oapiGetRotationMatrix (hObj, &rot); sdir = tmul (rot, -pos); double csun = sdir.y; @@ -424,8 +424,8 @@ bool vBase::RenderStructures(LPDIRECT3DDEVICE9 dev) // render generic objects above shadows for (DWORD i=0; iGetBoundingSpherePos(); - FVECTOR3 qw = TransformCoord(bs, mWorld); + auto bs = to_FVECTOR3(structure_as[i]->GetBoundingSpherePos()); + auto qw = TransformCoord(bs, to_FMATRIX4(mWorld)); D3D9Sun sp = vP->GetObjectAtmoParams(qw._V() + vP->CameraPos()); structure_as[i]->SetSunLight(&sp); structure_as[i]->Render(&mWorld, RENDER_BASE); @@ -478,7 +478,7 @@ void vBase::RenderGroundShadow(LPDIRECT3DDEVICE9 dev, float alpha) pCurrentVisual = this; VECTOR3 sd; - oapiGetGlobalPos(hObj, &sd); normalise(sd); + oapiGetGlobalPos(hObj, &sd); sd = unit(sd); MATRIX3 mRot; oapiGetRotationMatrix(hObj, &mRot); @@ -508,7 +508,7 @@ void vBase::RenderGroundShadow(LPDIRECT3DDEVICE9 dev, float alpha) float rad = structure_as[i]->BBox.bs.w; if (rad<250.0f) ToLocal(q, &a, &b); - else ToLocal(_V(0,0,0), &a, &b); + else ToLocal({0,0,0}, &a, &b); if (vP->GetElevation(a, b, &el0) <= 0) el0 = oapiSurfaceElevation(hPlanet, a, b); if (vP->GetElevation(a + d, b, &el1) <= 0) el1 = oapiSurfaceElevation(hPlanet, a + d, b); @@ -522,11 +522,11 @@ void vBase::RenderGroundShadow(LPDIRECT3DDEVICE9 dev, float alpha) vb = FromLocal(vb); vc = FromLocal(vc); - VECTOR3 n = -unit(crossp(vb - va, vc - va)); + VECTOR3 n = -unit(cross(vb - va, vc - va)); D3DXVECTOR3 hn = D3DXVEC(n); - float zo = float(-dotp(va, n)); + float zo = float(-dot(va, n)); float nd = D3DXVec3Dot(&hn, &lsun); hn /= nd; float ofs = zo / nd; diff --git a/OVP/D3D9Client/VObject.cpp b/OVP/D3D9Client/VObject.cpp index ebbf6c569..4f58aeb6f 100644 --- a/OVP/D3D9Client/VObject.cpp +++ b/OVP/D3D9Client/VObject.cpp @@ -61,7 +61,7 @@ vObject::vObject(OBJHANDLE _hObj, const Scene *scene) if (_hObj) size = oapiGetSize(_hObj); else size = 0; dmWorld = identity4(); - albedo = _V(1,1,1); + albedo = {1,1,1}; oapiGetObjectName(hObj, name, 64); sunLight = *scene->GetSun(); objtp = oapiGetObjectType(hObj); @@ -172,7 +172,7 @@ bool vObject::Update(bool bMainScene) oapiGetGlobalPos(hTgt, &tpos); - axis = mul(grot, _V(0, 1, 0)); + axis = mul(grot, VECTOR3{0, 1, 0}); cpos = gpos - scn->GetCameraGPos(); cdist = length(cpos); @@ -225,7 +225,7 @@ D3DXVECTOR3 vObject::GetBoundingSpherePosDX() VECTOR3 vObject::GetBoundingSpherePos() { D3DXVECTOR3 pos = GetBoundingSpherePosDX(); - return _V((double)pos.x, (double)pos.y, (double)pos.z); + return VECTOR3{(double)pos.x, (double)pos.y, (double)pos.z}; } @@ -285,7 +285,7 @@ void vObject::RenderSpot(LPDIRECT3DDEVICE9 dev, const VECTOR3 *ofs, float size, VECTOR3 camp = scn->GetCameraGPos(); const double ambient = 0.2; - double cosa = dotp (unit(gpos), unit(gpos - camp)); + double cosa = dot(unit(gpos), unit(gpos - camp)); double intens = (lighting ? 0.5 * ((1.0-ambient)*cosa + 1.0+ambient) : 1.0); D3DXMATRIX W; @@ -329,7 +329,7 @@ void vObject::RenderDot(LPDIRECT3DDEVICE9 dev) D3DXVec3Normalize(&vCam, &vPos); D3DMAT_CreateX_Billboard(&vCam, &vPos, scale, &W); - float ints = float(sqrt(1.0+dotp(unit(gpos-spos), unit(cpos)))) * 1.0f; + float ints = float(sqrt(1.0 + dot(unit(gpos - spos), unit(cpos)))) * 1.0f; if (ints>1.0f) ints=1.0f; @@ -360,24 +360,24 @@ void vObject::RenderVectors (LPDIRECT3DDEVICE9 dev, D3D9Pad* pSkp) //scale *= 0.99f; // 1% "slimmer" to avoid z-fighting with force vector(s) float ascale = float(size) * sclset * 0.5f; - RenderAxisVector(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha)), _V(1, 0, 0), ascale, scale); - RenderAxisLabel(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha)), _V(1, 0, 0), ascale, scale, "+X"); + RenderAxisVector(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha)), {1, 0, 0}, ascale, scale); + RenderAxisLabel(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha)), {1, 0, 0}, ascale, scale, "+X"); - RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha)), _V(0, 1, 0), ascale, scale); - RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha)), _V(0, 1, 0), ascale, scale, "+Y"); + RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha)), {0, 1, 0}, ascale, scale); + RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha)), {0, 1, 0}, ascale, scale, "+Y"); - RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha)), _V(0, 0, 1), ascale, scale); - RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha)), _V(0, 0, 1), ascale, scale, "+Z"); + RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha)), {0, 0, 1}, ascale, scale); + RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha)), {0, 0, 1}, ascale, scale, "+Z"); if (favmode & FAV_NEGATIVE) { - RenderAxisVector(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha * 0.5f)), _V(-1, 0, 0), ascale, scale); - RenderAxisLabel(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha)), _V(-1, 0, 0), ascale, scale, "-X"); + RenderAxisVector(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha * 0.5f)), {-1, 0, 0}, ascale, scale); + RenderAxisLabel(pSkp, ptr(D3DXCOLOR(1, 0, 0, alpha)), {-1, 0, 0}, ascale, scale, "-X"); - RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha * 0.5f)), _V(0, -1, 0), ascale, scale); - RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha)), _V(0, -1, 0), ascale, scale, "-Y"); + RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha * 0.5f)), {0, -1, 0}, ascale, scale); + RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 1, 0, alpha)), {0, -1, 0}, ascale, scale, "-Y"); - RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha * 0.5f)), _V(0, 0, -1), ascale, scale); - RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha)), _V(0, 0, -1), ascale, scale, "-Z"); + RenderAxisVector(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha * 0.5f)), {0, 0, -1}, ascale, scale); + RenderAxisLabel(pSkp, ptr(D3DXCOLOR(0, 0, 1, alpha)), {0, 0, -1}, ascale, scale, "-Z"); } } } @@ -395,11 +395,11 @@ void vObject::RenderAxisVector(D3D9Pad *pSkp, const D3DXCOLOR *pColor, VECTOR3 v VECTOR3 camp = gc->GetScene()->GetCameraGPos(); VECTOR3 pos = gpos - camp; - VECTOR3 rot = crossp(pos, vector); + VECTOR3 rot = cross(pos, vector); VECTOR3 y = mul (grot, unit(vector)) * size; VECTOR3 x = mul (grot, unit(rot)) * size; - VECTOR3 z = mul (grot, unit(crossp(vector, rot))) * size; + VECTOR3 z = mul (grot, unit(cross(vector, rot))) * size; D3DXMatrixIdentity(&W); @@ -431,11 +431,11 @@ void vObject::RenderAxisLabel(D3D9Pad *pSkp, const D3DXCOLOR *clr, VECTOR3 vecto VECTOR3 camp = gc->GetScene()->GetCameraGPos(); VECTOR3 pos = gpos - camp; - VECTOR3 rot = crossp(pos, vector); + VECTOR3 rot = cross(pos, vector); VECTOR3 y = mul(grot, unit(vector)) * size; VECTOR3 x = mul(grot, unit(rot)) * size; - VECTOR3 z = mul(grot, unit(crossp(vector, rot))) * size; + VECTOR3 z = mul(grot, unit(cross(vector, rot))) * size; D3DXMatrixIdentity(&W); diff --git a/OVP/D3D9Client/VPlanet.cpp b/OVP/D3D9Client/VPlanet.cpp index 330ee7516..4346538d2 100644 --- a/OVP/D3D9Client/VPlanet.cpp +++ b/OVP/D3D9Client/VPlanet.cpp @@ -17,25 +17,25 @@ #define D3D_OVERLOADS -#include -#include -#include - +#include "AtmoControls.h" +#include "CloudMgr.h" +#include "cloudmgr2.h" #include "D3D9Client.h" #include "D3D9Config.h" -#include "VPlanet.h" -#include "VBase.h" -#include "SurfMgr.h" -#include "surfmgr2.h" -#include "cloudmgr2.h" -#include "CloudMgr.h" -#include "HazeMgr.h" -#include "RingMgr.h" +#include "D3D9Util.h" #include "DebugControls.h" -#include "AtmoControls.h" -#include "VectorHelpers.h" -#include "OapiExtension.h" +#include "HazeMgr.h" #include "IProcess.h" +#include "OapiExtension.h" +#include "RingMgr.h" +#include "SurfMgr.h" +#include "surfmgr2.h" +#include "VBase.h" +#include "VPlanet.h" + +#include +#include +#include using namespace oapi; @@ -361,7 +361,7 @@ vPlanet::vPlanet (OBJHANDLE _hObj, const Scene *scene) : pSunColor(), pRaySkyView(), pMieSkyView(), pLandViewRay(), pLandViewMie(), pAmbientSky(), pLandViewAtn(), ShaderName("Auto\0") { memset(&MicroCfg, 0, sizeof(MicroCfg)); - vRefPoint = _V(1,0,0); + vRefPoint = {1,0,0}; atm_mode = 0; iConfig = 0; dist_scale = 1.0f; @@ -619,7 +619,7 @@ VECTOR3 vPlanet::GetUnitSurfacePos(double lng, double lat) const { double slat = sin(lat), clat = cos(lat); double slng = sin(lng), clng = cos(lng); - return _V(clat*clng, slat, clat*slng); + return {clat*clng, slat, clat*slng}; } // ============================================================== @@ -878,7 +878,7 @@ void vPlanet::CheckResolution() void vPlanet::RenderZRange (double *nplane, double *fplane) { - double d = dotp (scn->GetCameraGDir(), cpos); + double d = dot(scn->GetCameraGDir(), cpos); *fplane = max (1e3, d+size*1.2); *nplane = max (1e0, d-size*1.2); *fplane = min (*fplane, *nplane*1e5); @@ -913,7 +913,7 @@ bool vPlanet::Render(LPDIRECT3DDEVICE9 dev) { // Must update the latest view projection matrix - cp.mVP = *scn->GetProjectionViewMatrix(); + cp.mVP = to_FMATRIX4(*scn->GetProjectionViewMatrix()); // Setup shadow maps for surface base objects and mesh based bodies --------------- // @@ -947,7 +947,7 @@ bool vPlanet::Render(LPDIRECT3DDEVICE9 dev) prm.AmbColor = D3DXCOLOR(0,0,0,0); prm.FogColor = D3DXCOLOR(0,0,0,0); prm.TintColor = D3DXCOLOR(0,0,0,0); - prm.SunDir = _D3DXVECTOR3(SunDirection()); + prm.SunDir = to_D3DXVECTOR3(SunDirection()); if (ringmgr) { ringmgr->Render(dev, mWorld, false); @@ -999,7 +999,7 @@ bool vPlanet::Render(LPDIRECT3DDEVICE9 dev) // day/nighttime fog lighting VECTOR3 ppos; oapiGetGlobalPos (hObj, &ppos); - double cosa = dotp (unit(ppos), unit(cpos)); + double cosa = dot(unit(ppos), unit(cpos)); double bright = 1.0 * max (0.0, min (1.0, cosa + 0.3)); float rfog = (float)(bright*(min(1.0,fogcol.x)+0.0)); // "whiten" the fog colour float gfog = (float)(bright*(min(1.0,fogcol.y)+0.0)); @@ -1232,7 +1232,7 @@ bool vPlanet::ModLighting (DWORD &ambient) if (!prm.bAtm) return false; if (cdist >= size+prm.atm_href) return false; - double alpha = acos (dotp (unit(scn->GetCameraGPos()), -unit(cpos))); + double alpha = std::acos(dot(unit(scn->GetCameraGPos()), -unit(cpos))); // angular distance between sun and planet as seen from camera double sunelev = alpha - PI05; // elevation of sun above horizon (assuming camera on ground) @@ -1260,7 +1260,7 @@ VECTOR3 vPlanet::ReferencePoint() MATRIX3 mRot; oapiGetRotationMatrix(hObj, &mRot); VECTOR3 vLPos = unit(tmul(mRot, PosFromCamera())); - if (dotp(vLPos, vRefPoint)<0.9993) vRefPoint = vLPos; + if (dot(vLPos, vRefPoint) < 0.9993) vRefPoint = vLPos; return vRefPoint; } diff --git a/OVP/D3D9Client/VPlanetAtmo.cpp b/OVP/D3D9Client/VPlanetAtmo.cpp index 711b0b084..3a90b8534 100644 --- a/OVP/D3D9Client/VPlanetAtmo.cpp +++ b/OVP/D3D9Client/VPlanetAtmo.cpp @@ -8,16 +8,16 @@ #define D3D_OVERLOADS -#include -#include -#include - +#include "AtmoControls.h" #include "D3D9Client.h" #include "D3D9Config.h" -#include "VPlanet.h" -#include "AtmoControls.h" -#include "VectorHelpers.h" +#include "D3D9Util.h" #include "IProcess.h" +#include "VPlanet.h" + +#include +#include +#include using namespace oapi; @@ -595,9 +595,9 @@ void vPlanet::UpdateScatter() oapiGetRotationMatrix(hObj, &mRot); VECTOR3 vNrm = mul(mRot, ReferencePoint()); - VECTOR3 vRot = unit(mul(mRot, _V(0, 1, 0))); - VECTOR3 vTan = unit(crossp(vRot, vNrm)); - VECTOR3 vBiT = unit(crossp(vTan, vNrm)); + VECTOR3 vRot = unit(mul(mRot, VECTOR3{0, 1, 0})); + VECTOR3 vTan = unit(cross(vRot, vNrm)); + VECTOR3 vBiT = unit(cross(vTan, vNrm)); memcpy(&cp.mVP, scn->GetProjectionViewMatrix(), sizeof(FMATRIX4)); diff --git a/OVP/D3D9Client/VVessel.cpp b/OVP/D3D9Client/VVessel.cpp index 86dd4c4d4..67db883d4 100644 --- a/OVP/D3D9Client/VVessel.cpp +++ b/OVP/D3D9Client/VVessel.cpp @@ -333,7 +333,7 @@ void vVessel::InsertMesh(UINT idx) { _TRACE; - VECTOR3 ofs=_V(0,0,0); + VECTOR3 ofs{0, 0, 0}; UINT i; LPD3DXMATRIX pT = NULL; @@ -399,7 +399,7 @@ void vVessel::InsertMesh(UINT idx) // void vVessel::ResetMesh(UINT idx) { - VECTOR3 ofs = _V(0, 0, 0); + VECTOR3 ofs{0, 0, 0}; if ((idx < nmesh) && meshlist[idx].mesh) { @@ -721,9 +721,9 @@ bool vVessel::Render(LPDIRECT3DDEVICE9 dev, bool internalpass) // Initialize MeshShader constants // - MeshShader::ps_const.Cam_X = *scn->GetCameraX(); - MeshShader::ps_const.Cam_Y = *scn->GetCameraY(); - MeshShader::ps_const.Cam_Z = *scn->GetCameraZ(); + MeshShader::ps_const.Cam_X = to_FVECTOR3(*scn->GetCameraX()); + MeshShader::ps_const.Cam_Y = to_FVECTOR3(*scn->GetCameraY()); + MeshShader::ps_const.Cam_Z = to_FVECTOR3(*scn->GetCameraZ()); @@ -1043,14 +1043,14 @@ void vVessel::RenderGroundShadow(LPDIRECT3DDEVICE9 dev, OBJHANDLE hPlanet, float alt = d - R; // altitude above surface if (alt*eps > vessel->GetSize()) return; // too high to cast a shadow - normalise(sd); // shadow projection direction + sd = unit(sd); // shadow projection direction // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp(sd, pvr); + double fac1 = dot(sd, pvr); if (fac1 > 0.0) return; // shadow doesn't intersect planet surface double csun = -fac1 / d; // sun elevation above horizon if (csun < shadow_elev_limit) return; // sun too low to cast shadow - double arg = fac1*fac1 - (dotp(pvr, pvr) - R*R); + double arg = fac1 * fac1 - (dot(pvr, pvr) - R * R); if (arg <= 0.0) return; // shadow doesn't intersect with planet surface double a = -fac1 - sqrt(arg); @@ -1064,7 +1064,7 @@ void vVessel::RenderGroundShadow(LPDIRECT3DDEVICE9 dev, OBJHANDLE hPlanet, float // perform projections //double nr0 = dotp(hn, shp); float nr0 = float(-alt); - double nd = dotp(hn, sdv); + double nd = dot(hn, sdv); VECTOR3 sdvs = sdv / nd; D3DXVECTOR4 nrml = D3DXVECTOR4(float(hn.x), float(hn.y), float(hn.z), float(alt)); @@ -1107,7 +1107,7 @@ void vVessel::RenderGroundShadow(LPDIRECT3DDEVICE9 dev, OBJHANDLE hPlanet, float if (meshlist[i].trans) { VECTOR3 of; vessel->GetMeshOffset(i, of); - nrml.w += float(dotp(of, hn)); // Sift a local groung level + nrml.w += float(dot(of, hn)); // Sift a local groung level D3DXMatrixMultiply(&mProjWorldShift, meshlist[i].trans, &mProjWorld); mesh->RenderStencilShadows(alpha, &mWorld, &mProjWorldShift, false, &nrml); } @@ -1217,7 +1217,7 @@ bool vVessel::RenderENVMap(LPDIRECT3DDEVICE9 pDev, DWORD cnt, DWORD flags) // ----------------------------------------------------------------------------------------------- // VECTOR3 gpos; - vessel->Local2Global(_V(eCam->lPos.x, eCam->lPos.y, eCam->lPos.z), gpos); + vessel->Local2Global({eCam->lPos.x, eCam->lPos.y, eCam->lPos.z}, gpos); // Prepare camera and scene for env map rendering scn->PushCamera(); @@ -1333,7 +1333,7 @@ bool vVessel::ProbeIrradiance(LPDIRECT3DDEVICE9 pDev, DWORD cnt, DWORD flags) // ----------------------------------------------------------------------------------------------- // VECTOR3 gpos; - vessel->Local2Global(_V(0,0,0), gpos); + vessel->Local2Global({0,0,0}, gpos); // Prepare camera and scene for env map rendering scn->PushCamera(); @@ -1419,8 +1419,8 @@ void vVessel::RenderLightCone(LPD3DXMATRIX pWT) D3DXVECTOR3 Circle[65]; WORD CIdx[130]; - VECTOR3 _X = crossp(_D, _V(0.4, 0.2, -0.6)); - VECTOR3 _Y = crossp(_D, _X); + VECTOR3 _X = cross(_D, {0.4, 0.2, -0.6}); + VECTOR3 _Y = cross(_D, _X); D3DXVECTOR3 _x = D3DXVEC(_X); D3DXVECTOR3 _y = D3DXVEC(_Y); @@ -1711,9 +1711,9 @@ void vVessel::RenderReentry(LPDIRECT3DDEVICE9 dev) VECTOR3 d; vessel->GetShipAirspeedVector(d); vessel->GlobalRot(d, d); - normalise(d); + d = unit(d); - float x = float(dotp(d, unit(cpos))); + float x = float(dot(d, unit(cpos))); if (x<0) x=-x; x=pow(x,0.3f); float alpha_B = (x*0.40f + 0.60f) * ints; diff --git a/OVP/D3D9Client/VectorHelpers.h b/OVP/D3D9Client/VectorHelpers.h deleted file mode 100644 index 843084014..000000000 --- a/OVP/D3D9Client/VectorHelpers.h +++ /dev/null @@ -1,343 +0,0 @@ -// ================================================================================================================================= -// The MIT Lisence: -// -// Copyright (C) 2013-2016 Jarmo Nikkanen -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ================================================================================================================================= - - -#include "OrbiterAPI.h" -#include - - -#ifndef __VECTORHELPERS_H -#define __VECTORHELPERS_H - -#if defined(_MSC_VER) && (_MSC_VER >= 1900 ) // Microsoft Visual Studio Version 2015 and higher - // exp2() and log2() are defined in -#define _constexpr_ constexpr - -#else // older MSVC++ versions - -inline double exp2(double d) -{ - return exp(d*0.69314718055994530941723212145818); -} - -inline float exp2(float d) -{ - return exp(d*0.693147180559945f); -} - -inline double log2(double d) -{ - return log(d*1.4426950408889634073599246810019); -} -inline float log2(float d) -{ - return log(d*1.442695040888963f); -} - -inline double log1p(double d) -{ - return log(d+1.0); -} -// inline float log1p(float d) -// { -// return log(d+1.0f); -// } -#define _constexpr_ -#endif - -template inline _constexpr_ T sign (T val) -{ - return val < T(0) ? T(-1) : T(1); -} - -template inline _constexpr_ T lerp (T a, T b, T x) -{ - return a + (b - a)*x; -} -// ...slightly faster than the above, but not available in Visual Studio 2012 (I think)? -//template inline _constexpr_ T lerp(T v0, T v1, T t) { -// return fma(t, v1, fma(-t, v0, v0)); -//} - -template inline _constexpr_ T saturate (T val) -{ - return (val > T(1)) ? T(1) - : (val < T(0)) ? T(0) - : val; -} - -template inline _constexpr_ T clamp(T x, T a, T b) -{ - return x > b ? b - : x < a ? a - : x; -} - -template inline _constexpr_ T ilerp(T a, T b, T x) -{ - return saturate((x - a) / (b - a)); -} - -template inline _constexpr_ T sqr(T a) -{ - return a * a; -} - -template inline _constexpr_ T hermite(T a) -{ - return a * a * (T(3) - T(2)*a); -} - - -// VECTOR3 Helpers ================================================================== -// -inline VECTOR3 &operator+= (VECTOR3 &v, double d) -{ - v.x+=d; v.y+=d; v.z+=d; - return v; -} - -inline VECTOR3 &operator-= (VECTOR3 &v, double d) -{ - v.x-=d; v.y-=d; v.z-=d; - return v; -} - -inline VECTOR3 operator+ (const VECTOR3 &v, double d) -{ - return _V(v.x+d, v.y+d, v.z+d); -} - -inline VECTOR3 operator- (const VECTOR3 &v, double d) -{ - return _V(v.x-d, v.y-d, v.z-d); -} - -inline VECTOR3 operator- (double d, const VECTOR3 &v) -{ - return _V(d-v.x, d-v.y, d-v.z); -} - -inline VECTOR3 exp2(const VECTOR3 &v) -{ - return _V(exp2(v.x), exp2(v.y), exp2(v.z)); -} - -inline VECTOR3 rcp(const VECTOR3 &v) -{ - return _V(1.0/v.x, 1.0/v.y, 1.0/v.z); -} - -inline VECTOR3 vmax(const VECTOR3 &v, const VECTOR3 &w) -{ - return _V(std::max(v.x, w.x), std::max(v.y, w.y), std::max(v.z, w.z)); -} - -inline VECTOR3 vmin(const VECTOR3 &v, const VECTOR3 &w) -{ - return _V(std::min(v.x, w.x), std::min(v.y, w.y), std::min(v.z, w.z)); -} - - -// VECTOR4 Helpers ================================================================== -// -// -inline VECTOR4 &operator+= (VECTOR4 &v, double d) -{ - v.x+=d; v.y+=d; v.z+=d; v.w+=d; - return v; -} - -inline VECTOR4 &operator-= (VECTOR4 &v, double d) -{ - v.x-=d; v.y-=d; v.z-=d; v.w-=d; - return v; -} - -inline VECTOR4 operator+ (const VECTOR4 &v, double d) -{ - return _V(v.x+d, v.y+d, v.z+d, v.w+d); -} - -inline VECTOR4 operator- (const VECTOR4 &v, double d) -{ - return _V(v.x-d, v.y-d, v.z-d, v.w-d); -} - -inline VECTOR4 operator- (double d, const VECTOR4 &v) -{ - return _V(d-v.x, d-v.y, d-v.z, d-v.w); -} - -inline VECTOR4 &operator*= (VECTOR4 &v, double d) -{ - v.x*=d; v.y*=d; v.z*=d; v.w*=d; - return v; -} - -inline VECTOR4 &operator/= (VECTOR4 &v, double d) -{ - d=1.0/d; v.x*=d; v.y*=d; v.z*=d; v.w*=d; - return v; -} - -inline VECTOR4 operator* (const VECTOR4 &v, double d) -{ - return _V(v.x*d, v.y*d, v.z*d, v.w*d); -} - -inline VECTOR4 operator/ (const VECTOR4 &v, double d) -{ - d=1.0/d; return _V(v.x*d, v.y*d, v.z*d, v.w*d); -} - -inline double dotp(const VECTOR4 &v, const VECTOR4 &w) -{ - return v.x*w.x + v.y*w.y + v.z*w.z + v.w*w.w; -} - -inline double length(const VECTOR4 &v) -{ - return sqrt(dotp(v,v)); -} - -inline VECTOR4 normalize(const VECTOR4 &v) -{ - return v*(1.0/sqrt(dotp(v,v))); -} - -inline VECTOR4 exp2(const VECTOR4 &v) -{ - return _V(exp2(v.x), exp2(v.y), exp2(v.z), exp2(v.w)); -} - -inline VECTOR4 rcp(const VECTOR4 &v) -{ - return _V(1.0/v.x, 1.0/v.y, 1.0/v.z, 1.0/v.w); -} - -inline VECTOR4 vmax(const VECTOR4 &v, const VECTOR4 &w) -{ - return _V(std::max(v.x, w.x), std::max(v.y, w.y), std::max(v.z, w.z), std::max(v.w, w.w)); -} - -inline VECTOR4 vmin(const VECTOR4 &v, const VECTOR4 &w) -{ - return _V(std::min(v.x, w.x), std::min(v.y, w.y), std::min(v.z, w.z), std::min(v.w, w.w)); -} - - -// D3DXVECTOR3 Helpers ================================================================== -// -// - -inline D3DXVECTOR3 exp2(const D3DXVECTOR3 &v) -{ - return D3DXVECTOR3(exp2(v.x), exp2(v.y), exp2(v.z)); -} - -inline D3DXVECTOR3 _D3DXVECTOR3(const VECTOR3 &v) -{ - return D3DXVECTOR3(float(v.x), float(v.y), float(v.z)); -} - -inline D3DXVECTOR3 _D3DXVECTOR3(double x, double y, double z) -{ - return D3DXVECTOR3(float(x), float(y), float(z)); -} - -inline D3DXVECTOR3 operator* (const D3DXVECTOR3 &a, const D3DXVECTOR3 &b) -{ - return D3DXVECTOR3(a.x*b.x, a.y*b.y, a.z*b.z); -} - -inline D3DXVECTOR3 operator+ (const D3DXVECTOR3 &a, float d) -{ - return D3DXVECTOR3(a.x+d, a.y+d, a.z+d); -} - -inline D3DXVECTOR3 &operator*= (D3DXVECTOR3 &a, const D3DXVECTOR3 &b) -{ - a.x *= b.x; a.y *= b.y; a.z *= b.z; - return a; -} - -inline D3DXVECTOR3 &operator+= (D3DXVECTOR3 &a, float d) -{ - a.x += d; a.y += d; a.z += d; - return a; -} - -inline D3DXVECTOR3 rcp(const D3DXVECTOR3 &v) -{ - return D3DXVECTOR3(1.0f/v.x, 1.0f/v.y, 1.0f/v.z); -} - -inline D3DXVECTOR3 vmax(const D3DXVECTOR3 &v, const D3DXVECTOR3 &w) -{ - return D3DXVECTOR3(std::max(v.x, w.x), std::max(v.y, w.y), std::max(v.z, w.z)); -} - -inline D3DXVECTOR3 vmin(const D3DXVECTOR3 &v, const D3DXVECTOR3 &w) -{ - return D3DXVECTOR3(std::min(v.x, w.x), std::min(v.y, w.y), std::min(v.z, w.z)); -} - -inline D3DXVECTOR3 lerp(const D3DXVECTOR3 &v, const D3DXVECTOR3 &w, float x) -{ - return D3DXVECTOR3(v.x+(w.x-v.x)*x, v.y+(w.y-v.y)*x, v.z+(w.z-v.z)*x); -} - - - -// D3DXVECTOR4 Helpers ================================================================== -// -// -inline D3DXVECTOR4 abs(D3DXVECTOR4 &a) -{ - return D3DXVECTOR4(abs(a.x), abs(a.y), abs(a.z), abs(a.w)); -} - -inline D3DXVECTOR4 sign(D3DXVECTOR4 &a) -{ - return D3DXVECTOR4(sign(a.x), sign(a.y), sign(a.z), sign(a.w)); -} - -inline D3DXVECTOR4 pow(float x, D3DXVECTOR4 &y) -{ - return D3DXVECTOR4(pow(x, y.x), pow(x, y.y), pow(x, y.z), pow(x, y.w)); -} - -inline D3DXVECTOR4 operator- (const D3DXVECTOR4 &v, float d) -{ - return D3DXVECTOR4(v.x-d, v.y-d, v.z-d, v.w-d); -} - -inline D3DXVECTOR4 operator+ (const D3DXVECTOR4 &v, float d) -{ - return D3DXVECTOR4(v.x+d, v.y+d, v.z+d, v.w+d); -} - -inline D3DXVECTOR4 &operator*= (D3DXVECTOR4 &v, const D3DXVECTOR4 &d) -{ - v.x*=d.x; v.y*=d.y; v.z*=d.z; v.w*=d.w; - return v; -} - -#endif - diff --git a/OVP/D3D9Client/gcConst.h b/OVP/D3D9Client/gcConst.h index 9c4461c83..b537acdfa 100644 --- a/OVP/D3D9Client/gcConst.h +++ b/OVP/D3D9Client/gcConst.h @@ -659,7 +659,7 @@ class gcConst */ inline void WorldMatrix(FMATRIX4 *mat, const VECTOR3 &pos, const VECTOR3 &x, const VECTOR3 &z, double scale = 1.0) { - VECTOR3 y = crossp(x, z); + VECTOR3 y = cross(x, z); mat->m11 = float(x.x * scale); mat->m12 = float(x.y * scale); mat->m13 = float(x.z * scale); mat->m14 = 0.0f; mat->m21 = float(y.x * scale); mat->m22 = float(y.y * scale); mat->m23 = float(y.z * scale); mat->m24 = 0.0f; mat->m31 = float(z.x * scale); mat->m32 = float(z.y * scale); mat->m33 = float(z.z * scale); mat->m34 = 0.0f; diff --git a/OVP/D3D9Client/gcCore.cpp b/OVP/D3D9Client/gcCore.cpp index 7c9330d6a..164d8af24 100644 --- a/OVP/D3D9Client/gcCore.cpp +++ b/OVP/D3D9Client/gcCore.cpp @@ -182,7 +182,7 @@ void gcCore::ReleaseSwap(HSWAP hSwap) // CAMERAHANDLE gcCore::SetupCustomCamera(CAMERAHANDLE hCam, OBJHANDLE hVessel, VECTOR3 &pos, VECTOR3 &dir, VECTOR3 &up, double fov, SURFHANDLE hSurf, DWORD flags) { - VECTOR3 x = crossp(up, dir); + VECTOR3 x = cross(up, dir); MATRIX3 mTake; mTake.m11 = x.x; mTake.m21 = x.y; mTake.m31 = x.z; mTake.m12 = up.x; mTake.m22 = up.y; mTake.m32 = up.z; diff --git a/OVP/D3D9Client/gcCore.h b/OVP/D3D9Client/gcCore.h index f8634acab..f8695bad4 100644 --- a/OVP/D3D9Client/gcCore.h +++ b/OVP/D3D9Client/gcCore.h @@ -784,7 +784,7 @@ INTERFACE_BUILDER class gcCore */ inline void WorldMatrix(FMATRIX4* mat, const VECTOR3& pos, const VECTOR3& x, const VECTOR3& z, double scale = 1.0) { - VECTOR3 y = crossp(x, z); + VECTOR3 y = cross(x, z); mat->m11 = float(x.x * scale); mat->m12 = float(x.y * scale); mat->m13 = float(x.z * scale); mat->m14 = 0.0f; mat->m21 = float(y.x * scale); mat->m22 = float(y.y * scale); mat->m23 = float(y.z * scale); mat->m24 = 0.0f; mat->m31 = float(z.x * scale); mat->m32 = float(z.y * scale); mat->m33 = float(z.z * scale); mat->m34 = 0.0f; diff --git a/OVP/D3D9Client/samples/DrawOrbits/Draw.cpp b/OVP/D3D9Client/samples/DrawOrbits/Draw.cpp index 1e981566d..4eb49dac7 100644 --- a/OVP/D3D9Client/samples/DrawOrbits/Draw.cpp +++ b/OVP/D3D9Client/samples/DrawOrbits/Draw.cpp @@ -239,7 +239,7 @@ void Orbits::clbkPreStep(double simt, double simdt, double mjd) // Compute/Update orbit line intensity --------------------------------------- // Fade away orbits viewed from a shallow angle - float f = float(pow(abs(dotp(rdir, pO->_W)), 0.2)); + float f = float(std::pow(std::abs(dot(rdir, pO->_W)), 0.2)); if (f < 0.6f) f = 0.6f; @@ -328,7 +328,7 @@ void Orbits::SetClipper(Sketchpad *pSkp2, OBJHANDLE hObj, DWORD idx) Clip[idx].Pos = (bpos - CamPos); // Object position Clip[idx].dRad = dRad; - double len2 = dotp(Clip[idx].Pos, Clip[idx].Pos); + double len2 = dot(Clip[idx].Pos, Clip[idx].Pos); double hdst = sqrt(len2 - dRad*dRad); double ilen = 1.0 / sqrt(len2); @@ -396,7 +396,7 @@ bool Orbits::IsVisible(VECTOR3 pos, oapi::IVECTOR2 *pt, const SIZE &s) double len = length(pos); VECTOR3 uPos = pos / len; - for (int i = 0; i < 2; i++) if ((Clip[i].vcov < dotp(Clip[i].uPos, uPos)) && (len > Clip[i].hdst)) return false; + for (int i = 0; i < 2; i++) if ((Clip[i].vcov < dot(Clip[i].uPos, uPos)) && (len > Clip[i].hdst)) return false; return WorldToScreenSpace(pos, pt, pVP, s); } diff --git a/OVP/D3D9Client/samples/DrawOrbits/Orbit.cpp b/OVP/D3D9Client/samples/DrawOrbits/Orbit.cpp index 4000c42df..a0d161fd9 100644 --- a/OVP/D3D9Client/samples/DrawOrbits/Orbit.cpp +++ b/OVP/D3D9Client/samples/DrawOrbits/Orbit.cpp @@ -262,7 +262,7 @@ double COrbit::RelTrAByMJD(double mjd) const // double COrbit::TrAOfProjection(const VECTOR3 _p) const { - return limit(atan2(dotp(_p, _Q), dotp(_p, _P))); + return limit(std::atan2(dot(_p, _Q), dot(_p, _P))); } // ================================================================================================= @@ -270,7 +270,7 @@ double COrbit::TrAOfProjection(const VECTOR3 _p) const double COrbit::TrAOfAscendingNode(const VECTOR3 _n) const { VECTOR3 _p = crossp_LH(_n, _W); - return limit(atan2(dotp(_p, _Q), dotp(_p, _P))); + return limit(std::atan2(dot(_p, _Q), dot(_p, _P))); } // ================================================================================================= @@ -299,7 +299,7 @@ double COrbit::Inc() const double COrbit::LAN() const { VECTOR3 _p = crossp_LH(_Pol, _W); - double x = atan2(dotp(_p, _Aux), dotp(_p, _Equ)); + double x = std::atan2(dot(_p, _Aux), dot(_p, _Equ)); if (x<0) return PI2 + x; return x; } @@ -308,7 +308,7 @@ double COrbit::LAN() const double COrbit::AgP() const { VECTOR3 _p = crossp_LH(_Pol, _W); - return PI2 - limit(atan2(dotp(_p, _Q), dotp(_p, _P))); + return PI2 - limit(std::atan2(dot(_p, _Q), dot(_p, _P))); } // ================================================================================================= @@ -418,7 +418,7 @@ void COrbit::CreateFromStateVectors(const VECTOR3 &_pos, const VECTOR3 &_vel, do double om = 1.0 / mu; // Eccentricity VECTOR3 - _P = ((_pos * (v2 - mu* Or )) - (_vel * dotp(_pos, _vel))) * om; + _P = ((_pos * (v2 - mu* Or )) - (_vel * dot(_pos, _vel))) * om; _H = crossp_LH(_pos, _vel); _Q = unit(crossp_LH(_H, _P)); _R = _pos* Or ; @@ -430,7 +430,7 @@ void COrbit::CreateFromStateVectors(const VECTOR3 &_pos, const VECTOR3 &_vel, do ecc = 0.0; VECTOR3 _i = unit(crossp_LH(_K_ECL, _H)); VECTOR3 _j = unit(crossp_LH(_H, _i)); - _P = -unit(_j*dotp(_i, _J_ECL) - _i*dotp(_i, _I_ECL)); + _P = -unit(_j * dot(_i, _J_ECL) - _i * dot(_i, _I_ECL)); _Q = unit(crossp_LH(_H, _P)); par = sqrlen(_H)*om; sma = par; @@ -443,12 +443,12 @@ void COrbit::CreateFromStateVectors(const VECTOR3 &_pos, const VECTOR3 &_vel, do // Calculate True anomaly // - double x = dotp(_P, _R); + double x = dot(_P, _R); if (x >= 1.0) tra = 0.0; else if (x <= -1.0) tra = PI; else { tra = acos(x); - x = dotp(_pos, _vel); + x = dot(_pos, _vel); if (fabs(x)<1e-9) x = 0.0; // Avoid some precision problems if (x <= 0.0) tra = PI2 - tra; } @@ -508,7 +508,7 @@ void COrbit::CreateFromElements(const ELEMENTS *Elem, double iMu, double iEpoch) void COrbit::EscapeOrbit(const VECTOR3 &_Pos, const VECTOR3 &_Esc, double Mu, double MJD, double Dir) { VECTOR3 _H = crossp_LH(_Pos, _Esc); - double Es2 = dotp(_Esc, _Esc); + double Es2 = dot(_Esc, _Esc); mu = Mu; sma = -mu / Es2; diff --git a/OVP/D3D9Client/samples/DrawOrbits/Reference.cpp b/OVP/D3D9Client/samples/DrawOrbits/Reference.cpp index f44f6b770..5bd0dcadc 100644 --- a/OVP/D3D9Client/samples/DrawOrbits/Reference.cpp +++ b/OVP/D3D9Client/samples/DrawOrbits/Reference.cpp @@ -99,12 +99,12 @@ OBJHANDLE ReferenceClass::FindGravityReference(OBJHANDLE body) // Compute Eccentricity double myy = mass * GC; - double v = length(vel); - double r = length(pos); - double e = length( ( (pos * ((v*v)-(myy/r))) - (vel * dotp(pos,vel)) ) * (1/myy) ); + double v = len(vel); + double r = len(pos); + double e = len(((pos * ((v * v) - (myy / r))) - (vel * dot(pos, vel))) * (1 / myy)); if (e<1) { - distance=length(pos); + distance = len(pos); force=(GC*mass)/(distance*distance); if (force>gf) gf=force, gr_ref=obj, gr_dist=distance; } @@ -151,7 +151,7 @@ void ReferenceClass::CreateDatabase() if (References[j].grf_handle==ref && References[j].handle!=ref) { // Anything orbiting this object oapiGetRelativePos(References[j].handle,ref,&pos); // Compute it's distance - distance = length(pos) * 1.5; + distance = len(pos) * 1.5; if (References[i].dist0 && References[i].handle!=StarHandle) { // does this ReferenceClass have an distance setting nref=References[i].handle; oapiGetRelativePos(x,nref,&distance); - if (length(distance)GetGroupThrusterCount(engine); @@ -187,7 +187,7 @@ VECTOR3 GetThrusterGroupDir_LH(VESSEL *ship, THGROUP_TYPE engine) // VECTOR3 GetThrusterGroupThrustVector_LH(VESSEL *ship, THGROUP_TYPE engine) { - VECTOR3 d, dir = _V(0, 0, 0); + VECTOR3 d, dir = {0, 0, 0}; int i, c = ship->GetGroupThrusterCount(engine); for (i = 0; i= 1.0) return 0.0; else if (x <= -1.0) return PI; return(acos(x)); } @@ -145,7 +145,7 @@ inline double angle(const VECTOR3 &v, const VECTOR3 &h) /*! \details Return angle between two unit vectors */ inline double anglen(const VECTOR3 &v, const VECTOR3 &h) { - double x = dotp(v, h); + double x = dot(v, h); if (x >= 1.0) return 0.0; else if (x <= -1.0) return PI; return(acos(x)); } @@ -179,7 +179,7 @@ If they are allreay normalized use GetAngle2() instead. */ inline double GetAngle(const VECTOR3 &_p, const VECTOR3 &_I, const VECTOR3 &_J) { - double x = atan2(dotp(_p, unit(_J)), dotp(_p, unit(_I))); + double x = std::atan2(dot(_p, unit(_J)), dot(_p, unit(_I))); if (x<0) return PI2 + x; return x; } @@ -189,7 +189,7 @@ inputs are not normalized internally, must be normalized externally. Vector _p d */ inline double GetAngleN(const VECTOR3 &_p, const VECTOR3 &_I, const VECTOR3 &_J) { - double x = atan2(dotp(_p, _J), dotp(_p, _I)); + double x = std::atan2(dot(_p, _J), dot(_p, _I)); if (x<0) return PI2 + x; return x; } diff --git a/OVP/D3D9Client/samples/GenericCamera/MFD.cpp b/OVP/D3D9Client/samples/GenericCamera/MFD.cpp index f90b46446..402a10363 100644 --- a/OVP/D3D9Client/samples/GenericCamera/MFD.cpp +++ b/OVP/D3D9Client/samples/GenericCamera/MFD.cpp @@ -191,9 +191,9 @@ void CameraMFD::SelectVessel(VESSEL *hVes, Type _type) VECTOR3 pos, dir, rot; - pos = _V(0, 0, 0); - dir = _V(1, 0, 0); - rot = _V(0, 1, 0); + pos = {0, 0, 0}; + dir = {1, 0, 0}; + rot = {0, 1, 0}; type = _type; diff --git a/OVP/D3D9Client/samples/TerrainToolBox/Basics.cpp b/OVP/D3D9Client/samples/TerrainToolBox/Basics.cpp index c404116d8..fa3dd1fee 100644 --- a/OVP/D3D9Client/samples/TerrainToolBox/Basics.cpp +++ b/OVP/D3D9Client/samples/TerrainToolBox/Basics.cpp @@ -51,7 +51,7 @@ FMATRIX4 ToolKit::CreateWorldMatrix(OBJHANDLE hPlanet, double lng, double lat, d double rad = oapiGetSize(hPlanet) + elev; MATRIX3 mRot; oapiGetRotationMatrix(hPlanet, &mRot); - VECTOR3 vRot = mul(mRot, _V(0, 1, 0)); + VECTOR3 vRot = mul(mRot, VECTOR3{0, 1, 0}); VECTOR3 lpos, cpos, gp; oapiEquToLocal(hPlanet, lng, lat, rad, &lpos); @@ -63,8 +63,8 @@ FMATRIX4 ToolKit::CreateWorldMatrix(OBJHANDLE hPlanet, double lng, double lat, d FMATRIX4 m; VECTOR3 y = unit(lpos); // up - VECTOR3 x = unit(crossp(y, vRot)); // west - VECTOR3 z = crossp(x, y); // north + VECTOR3 x = unit(cross(y, vRot)); // west + VECTOR3 z = cross(x, y); // north VECTOR3 p = ((gp + lpos) - cpos); x *= scale; @@ -428,5 +428,5 @@ VECTOR3 ToolKit::GetSurfacePosUnit(double lng, double lat) MATRIX3 mRot; double w = cos(lat); oapiGetRotationMatrix(hPlanet, &mRot); - return mul(mRot, _V(w*cos(lng), sin(lat), w*sin(lng))); + return mul(mRot, VECTOR3{w * cos(lng), sin(lat), w * sin(lng)}); } diff --git a/Orbitersdk/include/DrawAPI.h b/Orbitersdk/include/DrawAPI.h index 1f7a303dd..c2a6a053b 100644 --- a/Orbitersdk/include/DrawAPI.h +++ b/Orbitersdk/include/DrawAPI.h @@ -21,11 +21,6 @@ #include "OrbiterAPI.h" #include -#include - -#ifdef D3D9CLIENT_EXPORTS -#include "d3dx9.h" -#endif /// \brief Poly object handle typedef void* HPOLY; @@ -210,20 +205,6 @@ namespace oapi { z = float(v.z); } -#ifdef D3D9CLIENT_EXPORTS - FVECTOR3(const D3DXVECTOR3 &v) - { - x = float(v.x); - y = float(v.y); - z = float(v.z); - } - FVECTOR3(const D3DXCOLOR& v) - { - x = float(v.r); - y = float(v.g); - z = float(v.b); - } -#endif float MaxRGB() const { return (std::max)(r, (std::max)(g, b)); @@ -335,16 +316,6 @@ namespace oapi { return FVECTOR3(-x, -y, -z); } -#ifdef D3D9CLIENT_EXPORTS - inline operator D3DXVECTOR3() const - { - return D3DXVECTOR3(x, y, z); - } - inline operator D3DXCOLOR() const - { - return D3DXCOLOR(x, y, z, 1); - } -#endif struct { float x, y, z; }; struct { float r, g, b; }; FVECTOR2 xy; @@ -472,24 +443,6 @@ namespace oapi { w = float(_w); } -#ifdef D3D9CLIENT_EXPORTS - FVECTOR4(const D3DXVECTOR4& v) - { - x = float(v.x); - y = float(v.y); - z = float(v.z); - w = float(v.w); - } - FVECTOR4(const D3DXCOLOR& v) - { - x = float(v.r); - y = float(v.g); - z = float(v.b); - w = float(v.a); - } -#endif - - inline FVECTOR4 operator* (float f) const { return FVECTOR4(x * f, y * f, z * f, w * f); @@ -552,13 +505,6 @@ namespace oapi { return FVECTOR4(-x, -y, -z, -w); } -#ifdef D3D9CLIENT_EXPORTS - inline operator D3DXVECTOR4() const - { - return D3DXVECTOR4(x, y, z, w); - } -#endif - __m128 xm; float data[4]; struct { float x, y, z, w; }; struct { float r, g, b, a; }; @@ -625,21 +571,6 @@ namespace oapi { for (int i = 0; i < 16; i++) data[i] = pSrc[i]; } -#ifdef D3D9CLIENT_EXPORTS - FMATRIX4(const D3DXMATRIX& m) - { - memcpy_s(data, sizeof(FMATRIX4), &m, sizeof(m)); - } - FMATRIX4(const LPD3DXMATRIX m) - { - memcpy_s(data, sizeof(FMATRIX4), m, sizeof(FMATRIX4)); - } - inline operator LPD3DXMATRIX() - { - return (LPD3DXMATRIX)this; - } -#endif - void Zero() { for (int i = 0; i < 16; i++) data[i] = 0.0; @@ -763,23 +694,14 @@ namespace oapi { return FVECTOR3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } - inline float saturate(float x) - { - //sadly std::clamp produces garbage assembly on both gcc and MSVC - //this version makes MSVC produce good code - x = (x < 0.0f) ? 0.0f : x; - x = (x > 1.0f) ? 1.0f : x; - return x; - } - inline FVECTOR3 saturate(const FVECTOR3& v) { - return FVECTOR3(saturate(v.x), saturate(v.y), saturate(v.z)); + return FVECTOR3(::saturate(v.x), ::saturate(v.y), ::saturate(v.z)); } inline FVECTOR4 saturate(const FVECTOR4& v) { - return FVECTOR4(saturate(v.x), saturate(v.y), saturate(v.z), saturate(v.w)); + return FVECTOR4(::saturate(v.x), ::saturate(v.y), ::saturate(v.z), ::saturate(v.w)); } inline FVECTOR2 lerp(const FVECTOR2& a, const FVECTOR2& b, float x) diff --git a/Orbitersdk/include/OrbiterAPI.h b/Orbitersdk/include/OrbiterAPI.h index 8f372c420..7831b565f 100644 --- a/Orbitersdk/include/OrbiterAPI.h +++ b/Orbitersdk/include/OrbiterAPI.h @@ -11,24 +11,28 @@ * \file OrbiterAPI.h * \brief General API interface functions * \todo Check functions in VESSELSTATUS2::arot and oapiGetPlanetObliquityMatrix(), - * minus sign has changed a place in a matrix. Is this correct?? + * minus sign has changed a place in a matrix. Is this correct?? * \todo class CameraMode documentation */ -#ifndef __ORBITERAPI_H -#define __ORBITERAPI_H +#ifndef ORBITERAPI_H +#define ORBITERAPI_H -#if defined(_MSC_VER) && (_MSC_VER >= 1300 ) // Microsoft Visual Studio Version 2003 and higher -#if !defined(_CRT_SECURE_NO_DEPRECATE) -#define _CRT_SECURE_NO_DEPRECATE -#endif +#if defined(_MSC_VER) && (_MSC_VER >= 1300) // Microsoft Visual Studio Version 2003 and higher + #if !defined(_CRT_SECURE_NO_DEPRECATE) + #define _CRT_SECURE_NO_DEPRECATE + #endif #endif + +#include "math.hpp" +#include "vector.hpp" + +#include #include -#include -#include -#include #include +#include + extern "C" { #include "Lua/lua.h" } @@ -39,18 +43,18 @@ extern "C" { #define DLLCLBK extern "C" __declspec(dllexport) #ifdef OAPI_IMPLEMENTATION -#define OAPIFUNC DLLEXPORT + #define OAPIFUNC DLLEXPORT #else -#define OAPIFUNC DLLIMPORT + #define OAPIFUNC DLLIMPORT #endif #pragma warning(disable: 4201) // Message loop return type - maintain backward compatibility for 32-bit #ifdef _WIN64 -#define OAPI_MSGTYPE LRESULT + #define OAPI_MSGTYPE LRESULT #else -#define OAPI_MSGTYPE int + #define OAPI_MSGTYPE int #endif // ====================================================================== @@ -60,11 +64,11 @@ extern "C" { const double PI = 3.14159265358979323846; ///< pi const double PI05 = 1.57079632679489661923; ///< pi/2 const double PI2 = 6.28318530717958647693; ///< pi*2 -const double RAD = PI/180.0; ///< factor to map degrees to radians -const double DEG = 180.0/PI; ///< factor to map radians to degrees -const double C0 = 299792458.0; ///< speed of light in vacuum [m/s] +const double RAD = PI / 180; ///< factor to map degrees to radians +const double DEG = 180 / PI; ///< factor to map radians to degrees +const double C0 = 299792458; ///< speed of light in vacuum [m/s] const double TAUA = 499.004783806; ///< light time for 1 AU [s] -const double AU = C0*TAUA; ///< astronomical unit (mean geocentric distance of the sun) [m] +const double AU = C0 * TAUA; ///< astronomical unit (mean geocentric distance of the sun) [m] const double GGRAV = 6.67259e-11; ///< gravitational constant [m^3 kg^-1 s^-2] const double G = 9.81; ///< gravitational acceleration [m/s^2] at Earth mean radius const double ATMP = 101.4e3; ///< atmospheric pressure [Pa] at Earth sea level @@ -79,10 +83,10 @@ const double ATMD = 1.293; ///< atmospheric density [kg/m^3] at Earth s * \param angle input angle [rad] * \return normalised angle [rad] */ -inline double normangle (double angle) +inline double normangle(double angle) { - double a = fmod (angle, PI2); - return (a >= PI ? a-PI2 : a < -PI ? a+PI2 : a); + double a = std::fmod(angle, PI2); + return a >= PI ? (a - PI2) : a < -PI ? (a + PI2) : a; } /** @@ -90,10 +94,10 @@ inline double normangle (double angle) * \param angle input angle [rad] * \return normalised angle [rad] */ -inline double posangle (double angle) +inline double posangle(double angle) { - double a = fmod (angle, PI2); - return (a >= 0.0 ? a : a+PI2); + double a = std::fmod(angle, PI2); + return a >= 0 ? a : (a + PI2); } /** @@ -106,7 +110,7 @@ inline double posangle (double angle) * with 'k', 'M', 'G' postfixes as required * \note cbuf must be allocated to sufficient size to hold the string */ -OAPIFUNC void FormatValue (char *cbuf, int n, double f, int precision=4); +OAPIFUNC void FormatValue(char *cbuf, int n, double f, int precision = 4); // ====================================================================== // API data types @@ -138,81 +142,79 @@ namespace oapi { // ====================================================================== //@{ /// \brief Handle for objects (vessels, stations, planets) -typedef void *OBJHANDLE; +using OBJHANDLE = void *; /// \brief Handle for vessel superstructures -typedef void *SUPERVESSELHANDLE; +using SUPERVESSELHANDLE = void *; /// \brief Handle for visuals -typedef void *VISHANDLE; +using VISHANDLE = void *; /// \brief Handle for meshes -typedef void *MESHHANDLE; +using MESHHANDLE = void *; /// \brief Handle for graphics-client-specific meshes -typedef int *DEVMESHHANDLE; -//struct DEVMESHHANDLE { -// DEVMESHHANDLE() { hMesh = NULL; } -// DEVMESHHANDLE(MESHHANDLE h) { hMesh = h; } -// DWORD id; -// MESHHANDLE hMesh; -// operator int() { return (int)hMesh; } -//}; +using DEVMESHHANDLE = int *; /// \brief Handle for bitmap surfaces and textures (panels and panel items) -typedef void *SURFHANDLE; +using SURFHANDLE = void *; /// \brief Handle for 2D instrument panels -typedef void *PANELHANDLE; +using PANELHANDLE = void *; /// \brief Handle for file streams -typedef void *FILEHANDLE; +using FILEHANDLE = void *; /// \brief Handle for script interpreters -typedef void *INTERPRETERHANDLE; +using INTERPRETERHANDLE = void *; /// \brief Handle for thrusters -typedef void *THRUSTER_HANDLE; +using THRUSTER_HANDLE = void *; /// \brief Handle for logical thruster groups -typedef void *THGROUP_HANDLE; +using THGROUP_HANDLE = void *; /// \brief Propellant resource handle -typedef void *PROPELLANT_HANDLE; +using PROPELLANT_HANDLE = void *; /// \brief Handle for particle streams -typedef void *PSTREAM_HANDLE; +using PSTREAM_HANDLE = void *; /// \brief Handle for vessel docking ports -typedef void *DOCKHANDLE; +using DOCKHANDLE = void *; /// \brief Handle vor vessel passive attachment points -typedef void *ATTACHMENTHANDLE; +using ATTACHMENTHANDLE = void *; /// \brief Handle for vessel airfoils -typedef void *AIRFOILHANDLE; +using AIRFOILHANDLE = void *; /// \brief Handle for vessel aerodynamic control surfaces -typedef void *CTRLSURFHANDLE; +using CTRLSURFHANDLE = void *; /// \brief Handle for a navigation radio transmitter (VOR, ILS, IDS, XPDR) -typedef void *NAVHANDLE; +using NAVHANDLE = void *; /// \brief Handle for animation components -typedef void *ANIMATIONCOMPONENT_HANDLE; +using ANIMATIONCOMPONENT_HANDLE = void *; /// \brief Handle for custom items added to Launchpad "Extra" list -typedef void *LAUNCHPADITEM_HANDLE; +using LAUNCHPADITEM_HANDLE = void *; /// \brief Handle for onscreen annotation objects -typedef void *NOTEHANDLE; +using NOTEHANDLE = void *; /// \brief Handle for elevation query managers -typedef void *ELEVHANDLE; +using ELEVHANDLE = void *; //@} -typedef enum { FILE_IN, FILE_OUT, FILE_APP, FILE_IN_ZEROONFAIL } FileAccessMode; -typedef enum { ROOT, CONFIG, SCENARIOS, TEXTURES, TEXTURES2, MESHES, MODULES } PathRoot; +enum FileAccessMode { + FILE_IN, FILE_OUT, FILE_APP, FILE_IN_ZEROONFAIL +}; + +enum PathRoot { + ROOT, CONFIG, SCENARIOS, TEXTURES, TEXTURES2, MESHES, MODULES +}; /// \defgroup surfid Identifiers for special render surfaces /// @{ @@ -231,22 +233,6 @@ typedef enum { ROOT, CONFIG, SCENARIOS, TEXTURES, TEXTURES2, MESHES, MODULES } P */ // =========================================================================== //@{ -/** - * \brief 3-element vector - */ -typedef union { - double data[3]; ///< array data interface - struct { double x, y, z; }; ///< named data interface -} VECTOR3; - -/** - * \brief 4-element vector - */ -typedef union { - double data[4]; ///< array data interface - struct { double x, y, z, w; }; ///< named data interface -} VECTOR4; - /** * \brief 3x3-element matrix */ @@ -6969,261 +6955,6 @@ OAPIFUNC void oapiTriggerRedrawArea (int panel_id, int vc_id, int area_id); // Some helper functions // ====================================================================== -/** - * \ingroup vec - * \brief Vector composition - * - * Returns a vector composed of the three provided arguments - * \param x x-component - * \param y y-component - * \param z z-component - * \return vector defined as (x,y,z) - */ -inline VECTOR3 _V(double x, double y, double z) -{ - VECTOR3 vec = {x,y,z}; return vec; -} - -/** - * \ingroup vec - * \brief Vector copy - * - * Copies the element values from the source to the target vector. - * \param[out] a target vector - * \param[in] b source vector - */ -inline void veccpy (VECTOR3 &a, const VECTOR3 &b) -{ - a.x = b.x; - a.y = b.y; - a.z = b.z; -} - -/** - * \ingroup vec - * \brief Vector addition - * \param a first vector operand - * \param b second vector operand - * \return Result of a+b. - */ -inline VECTOR3 operator+ (const VECTOR3 &a, const VECTOR3 &b) -{ - VECTOR3 c; - c.x = a.x+b.x; - c.y = a.y+b.y; - c.z = a.z+b.z; - return c; -} - -/** - * \ingroup vec - * \brief Vector subtraction - * \param a first vector operand - * \param b second vector operand - * \return Result of a-b. - */ -inline VECTOR3 operator- (const VECTOR3 &a, const VECTOR3 &b) -{ - VECTOR3 c; - c.x = a.x-b.x; - c.y = a.y-b.y; - c.z = a.z-b.z; - return c; -} - -/** - * \ingroup vec - * \brief Multiplication of vector with scalar - * \param a vector operand - * \param f scalar operand - * \return Result of element-wise a*f. - */ -inline VECTOR3 operator* (const VECTOR3 &a, const double f) -{ - VECTOR3 c; - c.x = a.x*f; - c.y = a.y*f; - c.z = a.z*f; - return c; -} - -/** - * \ingroup vec - * \brief Division of vector by a scalar - * \param a vector operand - * \param f scalar operand - * \return Result of element-wise a/f. - */ -inline VECTOR3 operator/ (const VECTOR3 &a, const double f) -{ - VECTOR3 c; - c.x = a.x/f; - c.y = a.y/f; - c.z = a.z/f; - return c; -} - -/** - * \ingroup vec - * \brief Vector addition-assignment a += b - * \param[in,out] a Left-hand vector operand - * \param[in] b Right-hand vector operand - * \return Replaces a with a+b and returns the result. - */ -inline VECTOR3 &operator+= (VECTOR3 &a, const VECTOR3 &b) -{ - a.x += b.x; - a.y += b.y; - a.z += b.z; - return a; -} - -/** - * \ingroup vec - * \brief Vector subtraction-assignment a -= b - * \param[in,out] a Left-hand vector operand - * \param[in] b Right-hand vector operand - * \return Replaces a with a-b and returns the result. - */ -inline VECTOR3 &operator-= (VECTOR3 &a, const VECTOR3 &b) -{ - a.x -= b.x; - a.y -= b.y; - a.z -= b.z; - return a; -} - -/** - * \ingroup vec - * \brief Vector-scalar multiplication-assignment a *= f - * \param[in,out] a Left-hand vector operand - * \param[in] f Right hand scalar operand - * \return Replaces a with element-wise a*f and returns the result. - */ -inline VECTOR3 &operator*= (VECTOR3 &a, const double f) -{ - a.x *= f; - a.y *= f; - a.z *= f; - return a; -} - -/** - * \ingroup vec - * \brief Vector-scalar division-assignment a /= f - * \param[in,out] a Left-hand vector operand - * \param[in] f Right-hand scalar operand - * \return Replaces a with element-wise a/f and returns the result. - */ -inline VECTOR3 &operator/= (VECTOR3 &a, const double f) -{ - a.x /= f; - a.y /= f; - a.z /= f; - return a; -} - -/** - * \ingroup vec - * \brief Vector unary minus -a - * \param[in] a Vector operand - * \return Negative vector (-a.x, -a.y, -a.z) - */ -inline VECTOR3 operator- (const VECTOR3 &a) -{ - VECTOR3 c; - c.x = -a.x; - c.y = -a.y; - c.z = -a.z; - return c; -} - -/** - * \ingroup vec - * \brief Scalar (inner, dot) product of two vectors - * \param[in] a First vector operand - * \param[in] b Second vector operand - * \return Scalar product ab - */ -inline double dotp (const VECTOR3 &a, const VECTOR3 &b) -{ - return a.x*b.x + a.y*b.y + a.z*b.z; -} - -/** - * \ingroup vec - * \brief Vector (cross) product of two vectors - * \param[in] a First vector operand - * \param[in] b Second vector operand - * \return Vector product axb - */ -inline VECTOR3 crossp (const VECTOR3 &a, const VECTOR3 &b) -{ - return _V(a.y*b.z - b.y*a.z, a.z*b.x - b.z*a.x, a.x*b.y - b.x*a.y); -} - -/** - * \ingroup vec - * \brief Length (L2-norm) of a vector - * \param a Vector operand - * \return Vector norm |a|2 - */ -inline double length (const VECTOR3 &a) -{ - return sqrt (a.x*a.x + a.y*a.y + a.z*a.z); -} - -/** - * \ingroup vec - * \brief Length squared of a vector - * \param a Vector operand - * \return Vector norm |a|22 - */ -inline double length2 (const VECTOR3 &a) -{ - return (a.x*a.x + a.y*a.y + a.z*a.z); -} - -/** - * \ingroup vec - * \brief Distance between two points - * \param[in] a First point - * \param[in] b Second point - * \return Distance between a and b - */ -inline double dist (const VECTOR3 &a, const VECTOR3 &b) -{ - return length (a-b); -} - -/** - * \ingroup vec - * \brief Normalise a vector - * - * Resizes the argument vector to length 1. - * \param[in,out] a Vector argument - * \note The length of a must be greater than 0. - */ -inline void normalise (VECTOR3 &a) -{ - a /= length(a); -} - -/** - * \ingroup vec - * \brief Returns normalised vector - * - * Returns a vector of length 1 with the same direction - * as the argument vector. - * \param[in] a Vector argument - * \return Normalised vector. - * \note The length of a must be greater than 0. - */ -inline VECTOR3 unit (const VECTOR3 &a) -{ - return a / length(a); -} - /** * \ingroup vec * \brief Matrix composition @@ -7377,12 +7108,13 @@ inline MATRIX3 &operator/= (MATRIX3 &A, double s) * \param[in] b vector operand * \return Result of Ab */ -inline VECTOR3 mul (const MATRIX3 &A, const VECTOR3 &b) +inline auto mul(const MATRIX3 &A, const VECTOR3 &b) { - return _V ( + return VECTOR3{ A.m11*b.x + A.m12*b.y + A.m13*b.z, A.m21*b.x + A.m22*b.y + A.m23*b.z, - A.m31*b.x + A.m32*b.y + A.m33*b.z); + A.m31*b.x + A.m32*b.y + A.m33*b.z + }; } /** @@ -7392,12 +7124,13 @@ inline VECTOR3 mul (const MATRIX3 &A, const VECTOR3 &b) * \param[in] b vector operand * \return Result of ATb */ -inline VECTOR3 tmul (const MATRIX3 &A, const VECTOR3 &b) +inline auto tmul(const MATRIX3 &A, const VECTOR3 &b) { - return _V ( + return VECTOR3{ A.m11*b.x + A.m21*b.y + A.m31*b.z, A.m12*b.x + A.m22*b.y + A.m32*b.z, - A.m13*b.x + A.m23*b.y + A.m33*b.z); + A.m13*b.x + A.m23*b.y + A.m33*b.z + }; } /** @@ -7519,9 +7252,12 @@ inline VECTOR3 POINTERTOREF (VECTOR3 *p) // ====================================================================== #ifdef ORBITER_MODULE + void dummy(); -void calldummy () { dummy(); } -DLLCLBK char *ModuleDate () { return (char*)__DATE__; } +void calldummy() { dummy(); } + +DLLCLBK char *ModuleDate() { return (char*)__DATE__; } + #endif -#endif // !__ORBITERAPI_H \ No newline at end of file +#endif // ORBITERAPI_H \ No newline at end of file diff --git a/Orbitersdk/include/math.hpp b/Orbitersdk/include/math.hpp new file mode 100644 index 000000000..548277ca8 --- /dev/null +++ b/Orbitersdk/include/math.hpp @@ -0,0 +1,19 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2023 Dimitry Ishenko +// Contact: dimitry (dot) ishenko (at) (gee) mail (dot) com +// +// Distributed under the MIT license. + +//////////////////////////////////////////////////////////////////////////////// +#ifndef MATH_HPP +#define MATH_HPP + +//////////////////////////////////////////////////////////////////////////////// +/** + * @brief return x saturated to the range [0, 1] +*/ +template +constexpr auto saturate(T x) { return x < T{0} ? T{0} : (x > T{1} ? T{1} : x); } + +//////////////////////////////////////////////////////////////////////////////// +#endif diff --git a/Orbitersdk/include/vector.hpp b/Orbitersdk/include/vector.hpp new file mode 100644 index 000000000..e101b7f8f --- /dev/null +++ b/Orbitersdk/include/vector.hpp @@ -0,0 +1,254 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2023 Dimitry Ishenko +// Contact: dimitry (dot) ishenko (at) (gee) mail (dot) com +// +// Distributed under the MIT license. + +//////////////////////////////////////////////////////////////////////////////// +#ifndef VECTOR_HPP +#define VECTOR_HPP + +#include +#include // std::size_t +#include // std::ostream +#include + +//////////////////////////////////////////////////////////////////////////////// +/** + * @brief type traits for 2-, 3- and 4-dimensional vectors + * + * Classes belonging to is_vector2 must have x and y member variables. + * Classes belonging to is_vector3 must have x, y and z member variables. + * Classes belonging to is_vector4 must have x, y, z and w member variables. + */ +template struct is_vector2 : std::false_type { }; +template struct is_vector3 : std::false_type { }; +template struct is_vector4 : std::false_type { }; + +//////////////////////////////////////////////////////////////////////////////// +/** + * @brief 3-dimensional vector of type double + */ +union VECTOR3 +{ + double data[3]; + struct { double x, y, z; }; + + constexpr auto const& operator[](std::size_t i) const { return data[i]; } + constexpr auto& operator[](std::size_t i) { return data[i]; } +}; + +/** + * @brief 4-dimensional vector of type double + */ +union VECTOR4 +{ + struct { double x, y, z, w; }; + + constexpr auto const& operator[](std::size_t i) const { const double* d[] = {&x, &y, &z, &w}; return *d[i]; } + constexpr auto& operator[](std::size_t i) { double* d[] = {&x, &y, &z, &w}; return *d[i]; } +}; + +template<> struct is_vector3 : std::true_type { }; +template<> struct is_vector4 : std::true_type { }; + +//////////////////////////////////////////////////////////////////////////////// +/** + * @brief helper macros for vector type traits + */ +#define if_vector2(V) std::enable_if_t::value>* = nullptr +#define if_vector3(V) std::enable_if_t::value>* = nullptr +#define if_vector4(V) std::enable_if_t::value>* = nullptr +#define if_vector( V) std::enable_if_t::value || is_vector3::value || is_vector4::value>* = nullptr + +/** + * @brief vector operators + */ +template constexpr auto& operator+=(V& l, const V& r) { l.x += r.x; l.y += r.y; return l; } +template constexpr auto& operator+=(V& l, const V& r) { l.x += r.x; l.y += r.y; l.z += r.z; return l; } +template constexpr auto& operator+=(V& l, const V& r) { l.x += r.x; l.y += r.y; l.z += r.z; l.w += r.w; return l; } + +template constexpr auto& operator+=(V& v, auto q) { v.x += q; v.y += q; return v; } +template constexpr auto& operator+=(V& v, auto q) { v.x += q; v.y += q; v.z += q; return v; } +template constexpr auto& operator+=(V& v, auto q) { v.x += q; v.y += q; v.z += q; v.w += q; return v; } + +template constexpr auto& operator-=(V& l, const V& r) { l.x -= r.x; l.y -= r.y; return l; } +template constexpr auto& operator-=(V& l, const V& r) { l.x -= r.x; l.y -= r.y; l.z -= r.z; return l; } +template constexpr auto& operator-=(V& l, const V& r) { l.x -= r.x; l.y -= r.y; l.z -= r.z; l.w -= r.w; return l; } + +template constexpr auto& operator-=(V& v, auto q) { v.x -= q; v.y -= q; return v; } +template constexpr auto& operator-=(V& v, auto q) { v.x -= q; v.y -= q; v.z -= q; return v; } +template constexpr auto& operator-=(V& v, auto q) { v.x -= q; v.y -= q; v.z -= q; v.w -= q; return v; } + +template constexpr auto& operator*=(V& l, const V& r) { l.x *= r.x; l.y *= r.y; return l; } +template constexpr auto& operator*=(V& l, const V& r) { l.x *= r.x; l.y *= r.y; l.z *= r.z; return l; } +template constexpr auto& operator*=(V& l, const V& r) { l.x *= r.x; l.y *= r.y; l.z *= r.z; l.w *= r.w; return l; } + +template constexpr auto& operator*=(V& v, auto q) { v.x *= q; v.y *= q; return v; } +template constexpr auto& operator*=(V& v, auto q) { v.x *= q; v.y *= q; v.z *= q; return v; } +template constexpr auto& operator*=(V& v, auto q) { v.x *= q; v.y *= q; v.z *= q; v.w *= q; return v; } + +template constexpr auto& operator/=(V& l, const V& r) { l.x /= r.x; l.y /= r.y; return l; } +template constexpr auto& operator/=(V& l, const V& r) { l.x /= r.x; l.y /= r.y; l.z /= r.z; return l; } +template constexpr auto& operator/=(V& l, const V& r) { l.x /= r.x; l.y /= r.y; l.z /= r.z; l.w /= r.w; return l; } + +template constexpr auto& operator/=(V& v, auto q) { v.x /= q; v.y /= q; return v; } +template constexpr auto& operator/=(V& v, auto q) { v.x /= q; v.y /= q; v.z /= q; return v; } +template constexpr auto& operator/=(V& v, auto q) { v.x /= q; v.y /= q; v.z /= q; v.w /= q; return v; } + +template constexpr auto operator+ (const V& v) { return V{+v.x, +v.y}; } // unary + +template constexpr auto operator+ (const V& v) { return V{+v.x, +v.y, +v.z}; } // unary + +template constexpr auto operator+ (const V& v) { return V{+v.x, +v.y, +v.z, +v.w}; } // unary + + +template constexpr auto operator- (const V& v) { return V{-v.x, -v.y}; } // unary - +template constexpr auto operator- (const V& v) { return V{-v.x, -v.y, -v.z}; } // unary - +template constexpr auto operator- (const V& v) { return V{-v.x, -v.y, -v.z, -v.w}; } // unary - + +template constexpr auto operator+ (const V& l, const V& r) { return V{l.x + r.x, l.y + r.y}; } +template constexpr auto operator+ (const V& l, const V& r) { return V{l.x + r.x, l.y + r.y, l.z + r.z}; } +template constexpr auto operator+ (const V& l, const V& r) { return V{l.x + r.x, l.y + r.y, l.z + r.z, l.w + r.w}; } + +template constexpr auto operator+ (const V& v, auto q) { return V{v.x + q, v.y + q}; } +template constexpr auto operator+ (const V& v, auto q) { return V{v.x + q, v.y + q, v.z + q}; } +template constexpr auto operator+ (const V& v, auto q) { return V{v.x + q, v.y + q, v.z + q, v.w + q}; } + +template constexpr auto operator+ (auto q, const V& v) { return V{q + v.x, q + v.y}; } +template constexpr auto operator+ (auto q, const V& v) { return V{q + v.x, q + v.y, q + v.z}; } +template constexpr auto operator+ (auto q, const V& v) { return V{q + v.x, q + v.y, q + v.z, q + v.w}; } + +template constexpr auto operator- (const V& l, const V& r) { return V{l.x - r.x, l.y - r.y}; } +template constexpr auto operator- (const V& l, const V& r) { return V{l.x - r.x, l.y - r.y, l.z - r.z}; } +template constexpr auto operator- (const V& l, const V& r) { return V{l.x - r.x, l.y - r.y, l.z - r.z, l.w - r.w}; } + +template constexpr auto operator- (const V& v, auto q) { return V{v.x - q, v.y - q}; } +template constexpr auto operator- (const V& v, auto q) { return V{v.x - q, v.y - q, v.z - q}; } +template constexpr auto operator- (const V& v, auto q) { return V{v.x - q, v.y - q, v.z - q, v.w - q}; } + +template constexpr auto operator- (auto q, const V& v) { return V{q - v.x, q - v.y}; } +template constexpr auto operator- (auto q, const V& v) { return V{q - v.x, q - v.y, q - v.z}; } +template constexpr auto operator- (auto q, const V& v) { return V{q - v.x, q - v.y, q - v.z, q - v.w}; } + +template constexpr auto operator* (const V& l, const V& r) { return V{l.x * r.x, l.y * r.y}; } +template constexpr auto operator* (const V& l, const V& r) { return V{l.x * r.x, l.y * r.y, l.z * r.z}; } +template constexpr auto operator* (const V& l, const V& r) { return V{l.x * r.x, l.y * r.y, l.z * r.z, l.w * r.w}; } + +template constexpr auto operator* (const V& v, auto q) { return V{v.x * q, v.y * q}; } +template constexpr auto operator* (const V& v, auto q) { return V{v.x * q, v.y * q, v.z * q}; } +template constexpr auto operator* (const V& v, auto q) { return V{v.x * q, v.y * q, v.z * q, v.w * q}; } + +template constexpr auto operator* (auto q, const V& v) { return V{q * v.x, q * v.y}; } +template constexpr auto operator* (auto q, const V& v) { return V{q * v.x, q * v.y, q * v.z}; } +template constexpr auto operator* (auto q, const V& v) { return V{q * v.x, q * v.y, q * v.z, q * v.w}; } + +template constexpr auto operator/ (const V& l, const V& r) { return V{l.x / r.x, l.y / r.y}; } +template constexpr auto operator/ (const V& l, const V& r) { return V{l.x / r.x, l.y / r.y, l.z / r.z}; } +template constexpr auto operator/ (const V& l, const V& r) { return V{l.x / r.x, l.y / r.y, l.z / r.z, l.w / r.w}; } + +template constexpr auto operator/ (const V& v, auto q) { return V{v.x / q, v.y / q}; } +template constexpr auto operator/ (const V& v, auto q) { return V{v.x / q, v.y / q, v.z / q}; } +template constexpr auto operator/ (const V& v, auto q) { return V{v.x / q, v.y / q, v.z / q, v.w / q}; } + +template constexpr auto operator/ (auto q, const V& v) { return V{q / v.x, q / v.y}; } +template constexpr auto operator/ (auto q, const V& v) { return V{q / v.x, q / v.y, q / v.z}; } +template constexpr auto operator/ (auto q, const V& v) { return V{q / v.x, q / v.y, q / v.z, q / v.w}; } + +template constexpr auto operator==(const V& l, const V& r) { return l.x == r.x && l.y == r.y; } +template constexpr auto operator==(const V& l, const V& r) { return l.x == r.x && l.y == r.y && l.z == r.z; } +template constexpr auto operator==(const V& l, const V& r) { return l.x == r.x && l.y == r.y && l.z == r.z && l.w == r.w; } + +template constexpr auto operator!=(const V& l, const V& r) { return l.r != r.x || l.y != r.y; } +template constexpr auto operator!=(const V& l, const V& r) { return l.r != r.x || l.y != r.y || l.z != r.z; } +template constexpr auto operator!=(const V& l, const V& r) { return l.r != r.x || l.y != r.y || l.z != r.z || l.w != r.w; } + +/** + * @brief stream insertion operators + */ +template inline auto& operator<<(std::ostream& os, const V& v) { os << v.x << ',' << v.y; return os; } +template inline auto& operator<<(std::ostream& os, const V& v) { os << v.x << ',' << v.y << ',' << v.z; return os; } +template inline auto& operator<<(std::ostream& os, const V& v) { os << v.x << ',' << v.y << ',' << v.z << ',' << v.w; return os; } + +//////////////////////////////////////////////////////////////////////////////// +/** + * @brief absolute value + */ +template constexpr auto abs(const V& v) { return V{std::abs(v.x), std::abs(v.y)}; } +template constexpr auto abs(const V& v) { return V{std::abs(v.x), std::abs(v.y), std::abs(v.z)}; } +template constexpr auto abs(const V& v) { return V{std::abs(v.x), std::abs(v.y), std::abs(v.z), std::abs(v.w)}; } + +/** + * @brief angle between two vectors + */ +template constexpr auto angle(const V& l, const V& r) { return std::acos( dot(unit(l), unit(r)) ); } + +/** + * @brief cross product + */ +template +constexpr auto cross(const V& l, const V& r) +{ + return V{l.y * r.z - r.y * l.z, l.z * r.x - r.z * l.x, l.x * r.y - r.x * l.y}; +} + +/** + * @brief distance between two points (squared and not) + */ +template constexpr auto dist_2(const V& l, const V& r) { return len_2(l - r); } +template constexpr auto dist(const V& l, const V& r) { return std::sqrt(dist_2(l, r)); } + +/** + * @brief dot (scalar) product + */ +template constexpr auto dot(const V& l, const V& r) { return l.x * r.x + l.y * r.y; } +template constexpr auto dot(const V& l, const V& r) { return l.x * r.x + l.y * r.y + l.z * r.z; } +template constexpr auto dot(const V& l, const V& r) { return l.x * r.x + l.y * r.y + l.z * r.z + l.w * r.w; } + +/** + * @brief e raised to the power + */ +template constexpr auto exp(const V& v) { return V{std::exp(v.x), std::exp(v.y)}; } +template constexpr auto exp(const V& v) { return V{std::exp(v.x), std::exp(v.y), std::exp(v.z)}; } +template constexpr auto exp(const V& v) { return V{std::exp(v.x), std::exp(v.y), std::exp(v.z), std::exp(v.w)}; } + +/** + * @brief linear interpolation + */ +template constexpr auto lerp(const V& a, const V& b, auto t) { return a + t * (b - a); } + +/** + * @brief vector norm/length (squared and not) + */ +template constexpr auto norm_2(const V& v) { return dot(v, v); } +template constexpr auto len_2 (const V& v) { return norm_2(v); } + +template constexpr auto norm(const V& v) { return std::sqrt(norm_2(v)); } +template constexpr auto len (const V& v) { return norm(v); } + +/** + * @brief raise to the power + */ +template constexpr auto pow(const V& l, const V& r) { return V{std::pow(l.x, r.x), std::pow(l.y, r.y)}; } +template constexpr auto pow(const V& l, const V& r) { return V{std::pow(l.x, r.x), std::pow(l.y, r.y), std::pow(l.z, r.z)}; } +template constexpr auto pow(const V& l, const V& r) { return V{std::pow(l.x, r.x), std::pow(l.y, r.y), std::pow(l.z, r.z), std::pow(l.w, r.w)}; } + +template constexpr auto pow(const V& v, auto e) { return V{std::pow(v.x, e), std::pow(v.y, e)}; } +template constexpr auto pow(const V& v, auto e) { return V{std::pow(v.x, e), std::pow(v.y, e), std::pow(v.z, e)}; } +template constexpr auto pow(const V& v, auto e) { return V{std::pow(v.x, e), std::pow(v.y, e), std::pow(v.z, e), std::pow(v.w, e)}; } + +template constexpr auto pow(auto b, const V& v) { return V{std::pow(b, v.x), std::pow(b, v.y)}; } +template constexpr auto pow(auto b, const V& v) { return V{std::pow(b, v.x), std::pow(b, v.y), std::pow(b, v.z)}; } +template constexpr auto pow(auto b, const V& v) { return V{std::pow(b, v.x), std::pow(b, v.y), std::pow(b, v.z), std::pow(b, v.w)}; } + +/** + * @brief square root + */ +template constexpr auto sqrt(const V& v) { return V{std::sqrt(v.x), std::sqrt(v.y)}; } +template constexpr auto sqrt(const V& v) { return V{std::sqrt(v.x), std::sqrt(v.y), std::sqrt(v.z)}; } +template constexpr auto sqrt(const V& v) { return V{std::sqrt(v.x), std::sqrt(v.y), std::sqrt(v.z), std::sqrt(v.w)}; } + +/** + * @brief normalized unit vector + */ +template constexpr auto unit(const V& v) { return v / len(v); } + +//////////////////////////////////////////////////////////////////////////////// +#endif diff --git a/Sound/XRSound/src/SoundPreSteps.cpp b/Sound/XRSound/src/SoundPreSteps.cpp index 4d5973b99..13401901f 100644 --- a/Sound/XRSound/src/SoundPreSteps.cpp +++ b/Sound/XRSound/src/SoundPreSteps.cpp @@ -347,7 +347,7 @@ const float RCSDefaultSoundPreStep::s_minThrustLevelForSound = 0.20f; RCSDefaultSoundPreStep::RCSDefaultSoundPreStep(VesselXRSoundEngine *pEngine) : DefaultSoundPreStep(pEngine) { - m_thrustVectorsROT = m_thrustVectorsLIN = _V(0, 0, 0); // set by value + m_thrustVectorsROT = m_thrustVectorsLIN = {0, 0, 0}; // set by value // we have six total axes, but need to check for both rotation and translation: rotation and translation for a given axis share the same sound slot const XRSoundConfigFileParser &config = m_pEngine->GetConfig(); diff --git a/Sound/XRSound/src/VesselXRSoundEngine.cpp b/Sound/XRSound/src/VesselXRSoundEngine.cpp index cba955644..26f673dc1 100644 --- a/Sound/XRSound/src/VesselXRSoundEngine.cpp +++ b/Sound/XRSound/src/VesselXRSoundEngine.cpp @@ -439,9 +439,8 @@ double VesselXRSoundEngine::GetCameraDistance() if (pVessel == nullptr) // vessel deleted out from under us? return 10.0; // just assume the camera is close - const VECTOR3 &zero = _V(0, 0, 0); VECTOR3 vesselGlobalCoords; - pVessel->Local2Global(zero, vesselGlobalCoords); + pVessel->Local2Global(VECTOR3{0, 0, 0}, vesselGlobalCoords); return dist(vesselGlobalCoords, GetCameraCoordinates()); } diff --git a/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp b/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp index d8b7a1efb..eed32716f 100644 --- a/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp +++ b/Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp @@ -1345,14 +1345,14 @@ int Interpreter::vec_add (lua_State *L) } else { ASSERT_SYNTAX (lua_isnumber(L,2), "Argument 2: expected vector or number"); fb = lua_tonumber (L,2); - lua_pushvector (L, _V(va.x+fb, va.y+fb, va.z+fb)); + lua_pushvector (L, {va.x+fb, va.y+fb, va.z+fb}); } } else { ASSERT_SYNTAX (lua_isnumber(L,1), "Argument 1: expected vector or number"); fa = lua_tonumber (L,1); if (lua_isvector (L,2)) { vb = lua_tovector (L,2); - lua_pushvector (L, _V(fa+vb.x, fa+vb.y, fa+vb.z)); + lua_pushvector (L, {fa+vb.x, fa+vb.y, fa+vb.z}); } else { ASSERT_SYNTAX (lua_isnumber(L,2), "Argument 2: expected vector or number"); fb = lua_tonumber (L,2); @@ -1374,14 +1374,14 @@ int Interpreter::vec_sub (lua_State *L) } else { ASSERT_SYNTAX (lua_isnumber(L,2), "Argument 2: expected vector or number"); fb = lua_tonumber (L,2); - lua_pushvector (L, _V(va.x-fb, va.y-fb, va.z-fb)); + lua_pushvector (L, {va.x-fb, va.y-fb, va.z-fb}); } } else { ASSERT_SYNTAX (lua_isnumber(L,1), "Argument 1: expected vector or number"); fa = lua_tonumber (L,1); if (lua_isvector (L,2)) { vb = lua_tovector (L,2); - lua_pushvector (L, _V(fa-vb.x, fa-vb.y, fa-vb.z)); + lua_pushvector (L, {fa-vb.x, fa-vb.y, fa-vb.z}); } else { ASSERT_SYNTAX (lua_isnumber(L,2), "Argument 2: expected vector or number"); fb = lua_tonumber (L,2); @@ -1462,7 +1462,7 @@ int Interpreter::vec_dotp (lua_State *L) v1 = lua_tovector(L,1); ASSERT_SYNTAX(lua_isvector(L,2), "Argument 2: expected vector"); v2 = lua_tovector(L,2); - lua_pushnumber (L, dotp(v1,v2)); + lua_pushnumber(L, dot(v1, v2)); return 1; } @@ -1473,7 +1473,7 @@ int Interpreter::vec_crossp (lua_State *L) v1 = lua_tovector(L,1); ASSERT_SYNTAX(lua_isvector(L,2), "Argument 2: expected vector"); v2 = lua_tovector(L,2); - lua_pushvector (L, crossp(v1,v2)); + lua_pushvector(L, cross(v1, v2)); return 1; } @@ -1482,7 +1482,7 @@ int Interpreter::vec_length (lua_State *L) VECTOR3 v; ASSERT_SYNTAX(lua_isvector(L,1), "Argument 1: expected vector"); v = lua_tovector(L,1); - lua_pushnumber (L, length(v)); + lua_pushnumber(L, len(v)); return 1; } @@ -1894,7 +1894,7 @@ int Interpreter::oapi_set_maininfovisibilitymode (lua_State *L) int Interpreter::oapiCreateAnnotation (lua_State *L) { NOTEHANDLE *pnote = (NOTEHANDLE*)lua_newuserdata (L, sizeof(NOTEHANDLE)); - *pnote = ::oapiCreateAnnotation (true, 1.0, _V(1,0.8,0.6)); + *pnote = ::oapiCreateAnnotation (true, 1.0, {1,0.8,0.6}); oapiAnnotationSetPos (*pnote, 0.03, 0.2, 0.4, 0.4); g_notehandles.push_back(pnote); diff --git a/Src/Module/LuaScript/LuaInterpreter/lua_vessel_mtd.cpp b/Src/Module/LuaScript/LuaInterpreter/lua_vessel_mtd.cpp index 1422e80bc..502b489b2 100644 --- a/Src/Module/LuaScript/LuaInterpreter/lua_vessel_mtd.cpp +++ b/Src/Module/LuaScript/LuaInterpreter/lua_vessel_mtd.cpp @@ -2347,7 +2347,7 @@ int Interpreter::v_get_progradedir (lua_State *L) v->GetRelativeVel (hRef, vel); v->GetRotationMatrix (rot); vel = tmul (rot, vel); // rotate into vessel frame - normalise (vel); + vel = unit(vel); lua_pushvector (L, vel); return 1; } diff --git a/Src/Orbiter/Base.h b/Src/Orbiter/Base.h index 0c45525ca..5c1f7c82d 100644 --- a/Src/Orbiter/Base.h +++ b/Src/Orbiter/Base.h @@ -130,7 +130,7 @@ class Base: public Body { // base local coordinates. // This version returns a stored value that is updated in regular intervals - inline Vector4 ShadowColor () const { return Vector4(0.0, 0.0, 0.0, 0.7); } + inline VECTOR4 ShadowColor () const { return VECTOR4{0.0, 0.0, 0.0, 0.7}; } // colour and transparency of shadows. Make this planet-specific DWORD GetTileList (const SurftileSpec **_tile) const; diff --git a/Src/Orbiter/Baseobj.cpp b/Src/Orbiter/Baseobj.cpp index d4313d4dc..4af165872 100644 --- a/Src/Orbiter/Baseobj.cpp +++ b/Src/Orbiter/Baseobj.cpp @@ -3533,7 +3533,7 @@ void SolarPlant::Activate () if (g_pOrbiter->Cfg()->CfgVisualPrm.bShadows) { ShVtx = new VERTEX_XYZ[nShVtx = npanel*4]; TRACENEW ShIdx = new WORD[nShIdx = npanel*6]; TRACENEW - Vector4 shadowCol = base->ShadowColor(); + auto shadowCol = base->ShadowColor(); D3DCOLOR shcol = D3DRGBA(shadowCol.x, shadowCol.y, shadowCol.z, shadowCol.w); for (n = 0; n < nShVtx; n++) { ShVtx[n].y = 0.0f; diff --git a/Src/Orbiter/CelSphereAPI.cpp b/Src/Orbiter/CelSphereAPI.cpp index c5b42c45e..102223d2a 100644 --- a/Src/Orbiter/CelSphereAPI.cpp +++ b/Src/Orbiter/CelSphereAPI.cpp @@ -28,7 +28,7 @@ oapi::CelestialSphere::CelestialSphere(oapi::GraphicsClient* gc) m_markerPen[i] = gc->clbkCreatePen(1, 0, MarkerColor(i)); m_textBlendAdditive = false; - m_skyCol = _V(0, 0, 0); + m_skyCol = {0, 0, 0}; m_skyBrt = 0.0; m_meshGridLabel = 0; diff --git a/Src/Orbiter/GraphicsAPI.cpp b/Src/Orbiter/GraphicsAPI.cpp index 8fd818197..7f51bd951 100644 --- a/Src/Orbiter/GraphicsAPI.cpp +++ b/Src/Orbiter/GraphicsAPI.cpp @@ -727,8 +727,8 @@ ParticleStream::ParticleStream (GraphicsClient *_gc, PARTICLESTREAMSPEC *pss) gc = _gc; level = NULL; hRef = NULL; - lpos = _V(0,0,0); pos = &lpos; - ldir = _V(0,0,0); dir = &ldir; + lpos = {0,0,0}; pos = &lpos; + ldir = {0,0,0}; dir = &ldir; } ParticleStream::~ParticleStream () @@ -815,7 +815,7 @@ void ScreenAnnotation::Reset () { ClearText(); SetPosition (0.1, 0.1, 0.5, 0.6); - SetColour (_V(1.0,0.7,0.2)); + SetColour ({1.0,0.7,0.2}); SetSize (1.0); } diff --git a/Src/Orbiter/LightEmitter.cpp b/Src/Orbiter/LightEmitter.cpp index ef3faac89..0d2641c18 100644 --- a/Src/Orbiter/LightEmitter.cpp +++ b/Src/Orbiter/LightEmitter.cpp @@ -23,8 +23,8 @@ LightEmitter::LightEmitter () col_diff.r = col_diff.g = col_diff.b = col_diff.a = 1.0f; col_spec.r = col_spec.g = col_spec.b = col_spec.a = 1.0f; col_ambi.r = col_ambi.g = col_ambi.b = col_ambi.a = 1.0f; - lpos = _V(0,0,0); pos = &lpos; - ldir = _V(0,0,1); dir = &ldir; + lpos = {0,0,0}; pos = &lpos; + ldir = {0,0,1}; dir = &ldir; lintens = 1.0; intens = &lintens; } @@ -39,8 +39,8 @@ LightEmitter::LightEmitter (COLOUR4 diffuse, COLOUR4 specular, COLOUR4 ambient) col_diff = diffuse; col_spec = specular; col_ambi = ambient; - lpos = _V(0,0,0); pos = &lpos; - ldir = _V(0,0,1); dir = &ldir; + lpos = {0,0,0}; pos = &lpos; + ldir = {0,0,1}; dir = &ldir; lintens = 1.0; intens = &lintens; } diff --git a/Src/Orbiter/Particle.cpp b/Src/Orbiter/Particle.cpp index a79aa34c8..242c284da 100644 --- a/Src/Orbiter/Particle.cpp +++ b/Src/Orbiter/Particle.cpp @@ -55,7 +55,7 @@ D3D7ParticleStream::D3D7ParticleStream (oapi::GraphicsClient *_gc, PARTICLESTREA { cam_ref = g_camera->GPOSPtr(); src_ref = 0; - src_ofs = _V(0,0,0); + src_ofs = {0,0,0}; interval = 0.1; SetSpecs (pss ? pss : &DefaultParticleStreamSpec); t0 = td.SimT0; @@ -232,7 +232,7 @@ double D3D7ParticleStream::MinCameraDist() const int i; for (p = pfirst, i = 0; p; p = p->next, i++) { if (!(i % 5)) { // only check every 5th particle for performance - double cdist = length2(*cam_ref - p->pos); + double cdist = len(*cam_ref - p->pos); if (cdist < min_cam_dist) { min_cam_dist = cdist; size = p->size; @@ -557,7 +557,7 @@ void ExhaustStream::Update () rad = oapiGetSize (hPlanet); if (vessel) rad += vessel->GetSurfaceElevation(); VECTOR3 dv = pp-plast->pos; // gravitational dv - double d = length (dv); + double d = len(dv); dv *= Ggrav * oapiGetMass(hPlanet)/(d*d*d) * td.SimDT; ATMPARAM prm; @@ -585,19 +585,19 @@ void ExhaustStream::Update () p->size += (alpha+alpha1) * td.SimDT; VECTOR3 s (p->pos - pp); - if (length(s) < rad) { - VECTOR3 dp = s * (rad/length(s)-1.0); + if (len(s) < rad) { + VECTOR3 dp = s * (rad / len(s) - 1.0); p->pos += dp; - static double dv_scale = length(vv)*0.2; + static double dv_scale = len(vv) * 0.2; VECTOR3 dv = {((double)rand()/(double)RAND_MAX-0.5)*dv_scale, ((double)rand()/(double)RAND_MAX-0.5)*dv_scale, ((double)rand()/(double)RAND_MAX-0.5)*dv_scale}; dv += vv; - normalise(s); - VECTOR3 vv2 = dv - s*dotp(s,dv); - if (length(vv2)) vv2 *= 0.5*length(vv)/length(vv2); + s = unit(s); + VECTOR3 vv2 = dv - s * dot(s, dv); + if (len(vv2)) vv2 *= 0.5 * len(vv) / len(vv2); vv2 += s*(((double)rand()/(double)RAND_MAX)*dv_scale); p->vel = vv2*1.0/*2.0*/+av; double r = (double)rand()/(double)RAND_MAX; @@ -686,9 +686,9 @@ void ExhaustStream::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, LPDIRECTDRAWSURFA } // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp (sd, pv0); + double fac1 = dot(sd, pv0); if (fac1 > 0.0) return; // shadow doesn't intersect planet surface - double arg = fac1*fac1 - (dotp (pv0, pv0) - rad*rad); + double arg = fac1 * fac1 - (dot(pv0, pv0) - rad * rad); if (arg <= 0.0) return; // shadow doesn't intersect with planet surface double a = -fac1 - sqrt(arg); VECTOR3 shp = sd*a; // projection point in global frame @@ -707,9 +707,9 @@ void ExhaustStream::RenderGroundShadow (LPDIRECT3DDEVICE7 dev, LPDIRECTDRAWSURFA VECTOR3 pvr = p->pos - pp; // rel. particle position // calculate the intersection of the vessel's shadow with the planet surface - double fac1 = dotp (sd, pvr); + double fac1 = dot(sd, pvr); if (fac1 > 0.0) break; // shadow doesn't intersect planet surface - double arg = fac1*fac1 - (dotp (pvr, pvr) - rad*rad); + double arg = fac1 * fac1 - (dot(pvr, pvr) - rad * rad); if (arg <= 0.0) break; // shadow doesn't intersect with planet surface double a = -fac1 - sqrt(arg); @@ -746,7 +746,7 @@ ReentryStream::ReentryStream (oapi::GraphicsClient *_gc, OBJHANDLE hV, PARTICLES : D3D7ParticleStream (_gc, pss) { llevel = 1.0; - Attach (hV, _V(0,0,0), _V(0,0,0), &llevel); + Attach (hV, {0,0,0}, {0,0,0}, &llevel); hPlanet = 0; } diff --git a/Src/Orbiter/Planet.cpp b/Src/Orbiter/Planet.cpp index 335b787de..4faf6408a 100644 --- a/Src/Orbiter/Planet.cpp +++ b/Src/Orbiter/Planet.cpp @@ -646,7 +646,7 @@ void Planet::ScanLabelLists (ifstream &cfg) if (!pc || sscanf (pc, "%lf%lf", &lng, &lat) != 2) continue; EquatorialToLocal (RAD*lng, RAD*lat, size, pos); oapi::GraphicsClient::LABELSPEC ls; - ls.pos = _V(pos.x, pos.y, pos.z); + ls.pos = {pos.x, pos.y, pos.z}; for (i = 0; i < 2; i++) { if (pc = strtok (NULL, ":")) ls.label[i] = trim_string(pc); diff --git a/Src/Orbiter/Star.cpp b/Src/Orbiter/Star.cpp index 5ae0b9af1..0e09bf2a4 100644 --- a/Src/Orbiter/Star.cpp +++ b/Src/Orbiter/Star.cpp @@ -72,11 +72,6 @@ Vector Star::Pos2Barycentre (Vector &pos) return Vector(); } -Vector4 Star::GetLightColor () -{ - return {1,1,1,1}; -} - #ifdef INLINEGRAPHICS void Star::InitDeviceObjects () { diff --git a/Src/Orbiter/Star.h b/Src/Orbiter/Star.h index 6f2581ade..e74af8f45 100644 --- a/Src/Orbiter/Star.h +++ b/Src/Orbiter/Star.h @@ -32,7 +32,7 @@ class Star: public CelestialBody { Vector Pos2Barycentre (Vector &pos); - Vector4 GetLightColor(); + auto GetLightColor() { return VECTOR4{1, 1, 1, 1}; } #ifdef INLINEGRAPHICS void InitDeviceObjects (); diff --git a/Src/Orbiter/Util.h b/Src/Orbiter/Util.h index 3cd4ae2c5..e5497f28c 100644 --- a/Src/Orbiter/Util.h +++ b/Src/Orbiter/Util.h @@ -36,8 +36,8 @@ bool iequal(const std::string& s1, const std::string& s2); inline Vector MakeVector (const VECTOR3 &v) { return Vector(v.x, v.y, v.z); } -inline VECTOR3 MakeVECTOR3 (const Vector &v) -{ return _V(v.x, v.y, v.z); } +inline auto MakeVECTOR3 (const Vector &v) +{ return VECTOR3{v.x, v.y, v.z}; } inline VECTOR4 MakeVECTOR4 (const Vector &v) { return _V(v.x, v.y, v.z, 1.0); } diff --git a/Src/Orbiter/VCockpit.cpp b/Src/Orbiter/VCockpit.cpp index c6fe3b49a..dc39ebc20 100644 --- a/Src/Orbiter/VCockpit.cpp +++ b/Src/Orbiter/VCockpit.cpp @@ -333,14 +333,14 @@ bool VirtualCockpit::SetClickZone_Quadrilateral (int i, area[i]->p[3].x, area[i]->p[3].y, area[i]->p[3].z, 1 ); Matrix4 P2(P1); - Vector4 cc, dd, r; - Vector4 u(0,1,0,1), v(0,0,1,1); + VECTOR4 cc{ }, dd{ }; + VECTOR4 u{0, 1, 0, 1}, v{0, 0, 1, 1}; qrdcmp (P1, cc, dd); qrsolv (P1, cc, dd, u); - for (j = 0; j < 4; j++) area[i]->u[j] = (float)u(j); + for (j = 0; j < 4; j++) area[i]->u[j] = (float)u[j]; qrdcmp (P2, cc, dd); qrsolv (P2, cc, dd, v); - for (j = 0; j < 4; j++) area[i]->v[j] = (float)v(j); + for (j = 0; j < 4; j++) area[i]->v[j] = (float)v[j]; area[i]->cmode = Area::CMODE_QUAD; return true; diff --git a/Src/Orbiter/Vecmat.cpp b/Src/Orbiter/Vecmat.cpp index 963266f0b..3c8149ebf 100644 --- a/Src/Orbiter/Vecmat.cpp +++ b/Src/Orbiter/Vecmat.cpp @@ -281,7 +281,7 @@ Matrix4::Matrix4 (const Matrix4 &A) } -void qrdcmp (Matrix4 &a, Vector4 &c, Vector4 &d, int *sing) +void qrdcmp (Matrix4 &a, VECTOR4 &c, VECTOR4 &d, int *sing) { int i, j, k; double scale, sigma, sum, tau; @@ -293,7 +293,7 @@ void qrdcmp (Matrix4 &a, Vector4 &c, Vector4 &d, int *sing) scale = std::max (scale, fabs(a(i,k))); if (scale == 0.0) { if (sing) *sing = 1; - c(k) = d(k) = 0.0; + c[k] = d[k] = 0.0; } else { for (i = k; i < 4; i++) a(i,k) /= scale; @@ -301,43 +301,43 @@ void qrdcmp (Matrix4 &a, Vector4 &c, Vector4 &d, int *sing) sum += a(i,k)*a(i,k); sigma = (a(k,k) < 0 ? -sqrt(sum) : sqrt(sum)); a(k,k) += sigma; - c(k) = sigma*a(k,k); - d(k) = -scale*sigma; + c[k] = sigma * a(k, k); + d[k] = -scale * sigma; for (j = k+1; j < 4; j++) { for (sum = 0.0,i = k; i < 4; i++) sum += a(i,k)*a(i,j); - tau = sum/c(k); + tau = sum / c[k]; for (i = k; i < 4; i++) a(i,j) -= tau*a(i,k); } } } - d(3) = a(3,3); - if (sing && d(3) == 0.0) *sing = 1; + d[3] = a(3, 3); + if (sing && d[3] == 0.0) *sing = 1; } -void qrsolv (const Matrix4 &a, const Vector4 &c, const Vector4 &d, Vector4 &b) +void qrsolv (const Matrix4 &a, const VECTOR4 &c, const VECTOR4 &d, VECTOR4 &b) { int i, j; double sum, tau; for (j = 0; j < 3; j++) { for (sum = 0.0, i = j; i < 4; i++) - sum += a(i,j)*b(i); - tau = sum/c(j); + sum += a(i, j) * b[i]; + tau = sum / c[j]; for (i = j; i < 4; i++) - b(i) -= tau*a(i,j); + b[i] -= tau * a(i, j); } - b(3) /= d(3); + b[3] /= d[3]; for (i = 2; i >= 0; i--) { for (sum = 0.0, j = i+1; j < 4; j++) - sum += a(i,j)*b(j); - b(i) = (b(i)-sum)/d(i); + sum += a(i, j) * b[j]; + b[i] = (b[i] - sum) / d[i]; } } -void QRFactorize (Matrix4 &A, Vector4 &c, Vector4 &d) +void QRFactorize (Matrix4 &A, VECTOR4 &c, VECTOR4 &d) { int i, j, k; double sum, b, f; @@ -345,9 +345,9 @@ void QRFactorize (Matrix4 &A, Vector4 &c, Vector4 &d) for (k = 0; k < 4; k++) { for (sum = 0, i = k; i < 4; i++) sum += A(i,k)*A(i,k); - d(k) = (A(k,k) < 0 ? -sqrt(sum) : sqrt(sum)); - b = sqrt(2.0*d(k)*(A(k,k) + d(k))); - A(k,k) = (A(k,k) + d(k))/b; + d[k] = A(k, k) < 0 ? -sqrt(sum) : sqrt(sum); + b = sqrt(2.0 * d[k] * (A(k, k) + d[k])); + A(k, k) = (A(k, k) + d[k]) / b; for (i = k+1; i < 4; i++) A(i,k) /= b; for (j = k+1; j < 4; j++) { @@ -360,20 +360,20 @@ void QRFactorize (Matrix4 &A, Vector4 &c, Vector4 &d) } } -void RSolve (const Matrix4 &A, const Vector4 &d, Vector4 &b) +void RSolve (const Matrix4 &A, const VECTOR4 &d, VECTOR4 &b) { int i, j; double sum; - b(3) /= -d(3); + b[3] /= -d[3]; for (i = 2; i >= 0; i--) { for (sum = 0.0, j = i+1; j < 4; j++) - sum += A(i,j) * b(j); - b(i) = (b(i)-sum) / -d(i); + sum += A(i, j) * b[j]; + b[i] = (b[i] - sum) / -d[i]; } } -void QRSolve (const Matrix4 &A, const Vector4 &c, - const Vector4 &d, const Vector4 &b, Vector4 &x) +void QRSolve (const Matrix4 &A, const VECTOR4 &c, + const VECTOR4 &d, const VECTOR4 &b, VECTOR4 &x) { int i, k; double sum; @@ -382,10 +382,10 @@ void QRSolve (const Matrix4 &A, const Vector4 &c, x = b; for (k = 0; k < 4; k++) { for (sum = 0, i = k; i < 4; i++) - sum += A(i,k)*x(i); + sum += A(i,k) * x[i]; sum *= 2.0; for (i = k; i < 4; i++) - x(i) -= sum*A(i,k); + x[i] -= sum * A(i, k); } // Solves Rx = y diff --git a/Src/Orbiter/Vecmat.h b/Src/Orbiter/Vecmat.h index cf1179f53..99fe28ef9 100644 --- a/Src/Orbiter/Vecmat.h +++ b/Src/Orbiter/Vecmat.h @@ -4,6 +4,8 @@ #ifndef __VECMAT_H #define __VECMAT_H +#include "vector.hpp" + #include #include #include @@ -231,38 +233,6 @@ Vector tmul (const Matrix &A, const Vector &b); // returns A^T * b Matrix inv (const Matrix &A); // inverse of A Matrix transp (const Matrix &A); // transpose of A -// ======================================================================= -// class Vector4: 4-element vector - -class Vector4 { -public: - inline Vector4 () - { x = y = z = w = 0.0; } - - inline Vector4 (double _x, double _y, double _z, double _w) - { x = _x, y = _y, z = _z, w = _w; } - - inline Vector4 (const Vector4 &vec) - { memcpy (data, vec.data, 4*sizeof(double)); } - - inline void Set (double _x, double _y, double _z, double _w) - { x = _x, y = _y, z = _z, w = _w; } - - inline void Set (const Vector4 &vec) - { memcpy (data, vec.data, 4*sizeof(double)); } - - inline double &operator() (int i) - { return data[i]; } - - inline double operator() (int i) const - { return data[i]; } - - union { - double data[4]; - struct { double x, y, z, w; }; - }; -}; - // ======================================================================= // class Matrix4: 4x4 dense matrix @@ -298,12 +268,12 @@ class Matrix4 { inline double operator() (int i, int j) const { return data[i*4+j]; } - friend void qrdcmp (Matrix4 &a, Vector4 &c, Vector4 &d, int *sing = 0); - friend void qrsolv (const Matrix4 &a, const Vector4 &c, const Vector4 &d, Vector4 &b); - friend void QRFactorize (Matrix4 &A, Vector4 &c, Vector4 &d); - friend void RSolve (const Matrix4 &A, const Vector4 &d, Vector4 &b); - friend void QRSolve (const Matrix4 &A, const Vector4 &c, - const Vector4 &d, const Vector4 &b, Vector4 &x); + friend void qrdcmp (Matrix4 &a, VECTOR4 &c, VECTOR4 &d, int *sing = 0); + friend void qrsolv (const Matrix4 &a, const VECTOR4 &c, const VECTOR4 &d, VECTOR4 &b); + friend void QRFactorize (Matrix4 &A, VECTOR4 &c, VECTOR4 &d); + friend void RSolve (const Matrix4 &A, const VECTOR4 &d, VECTOR4 &b); + friend void QRSolve (const Matrix4 &A, const VECTOR4 &c, + const VECTOR4 &d, const VECTOR4 &b, VECTOR4 &x); union { double data[16]; diff --git a/Src/Orbiter/VectorMap.cpp b/Src/Orbiter/VectorMap.cpp index 257345325..eac312e8b 100644 --- a/Src/Orbiter/VectorMap.cpp +++ b/Src/Orbiter/VectorMap.cpp @@ -1518,7 +1518,7 @@ void CustomMkrSpec::Convert () for (int i = 0; i < nvtx; i++) { VECTOR3 &p = list->marker[i].pos; vtx[i].lng = atan2 (p.z, p.x); - vtx[i].lat = asin (p.y / length(p)); + vtx[i].lat = std::asin(p.y / len(p)); } } diff --git a/Src/Orbiter/Vessel.cpp b/Src/Orbiter/Vessel.cpp index 2b87c8bfa..843fc1e15 100644 --- a/Src/Orbiter/Vessel.cpp +++ b/Src/Orbiter/Vessel.cpp @@ -376,9 +376,9 @@ void Vessel::DefaultGenericCaps () mu = 0.5; // default isotropic/lateral friction coefficient mu_lng = 0.1; // default longitudinal friction coefficient TOUCHDOWNVTX tdvtx[3]; - tdvtx[0].pos = _V( 0,-2,10); - tdvtx[1].pos = _V(-3,-2,-5); - tdvtx[2].pos = _V( 3,-2,-5); + tdvtx[0].pos = { 0,-2,10}; + tdvtx[1].pos = {-3,-2,-5}; + tdvtx[2].pos = { 3,-2,-5}; for (i = 0; i < 3; i++) { tdvtx[i].stiffness = 1e6; tdvtx[i].damping = 1e5; @@ -1523,7 +1523,7 @@ ThrustGroupSpec *Vessel::CreateThrusterGroup (ThrustSpec **ts, DWORD nts, THGROU if (thgt >= THGROUP_ATT_PITCHUP && thgt <= THGROUP_ATT_BANKRIGHT) { Vector M; for (i = 0; i < nts; i++) - M += MakeVector(crossp (ts[i]->dir * ts[i]->maxth0, ts[i]->ref)); + M += MakeVector(cross(ts[i]->dir * ts[i]->maxth0, ts[i]->ref)); max_angular_moment[thgt-THGROUP_ATT_PITCHUP] = M.length(); } @@ -2162,7 +2162,7 @@ UINT Vessel::AddExhaust (EXHAUSTSPEC *spec) es->flags &= ~EXHAUST_CONSTANTPOS; } else if (!es->lpos || (es->flags & EXHAUST_CONSTANTPOS)) { es->lpos = new VECTOR3; - *es->lpos = (spec->lpos ? *spec->lpos : _V(0,0,0)); + *es->lpos = (spec->lpos ? *spec->lpos : VECTOR3{0,0,0}); es->flags |= EXHAUST_CONSTANTPOS; } @@ -2171,7 +2171,7 @@ UINT Vessel::AddExhaust (EXHAUSTSPEC *spec) es->flags &= ~EXHAUST_CONSTANTDIR; } else if (!es->ldir || (es->flags & EXHAUST_CONSTANTDIR)) { es->ldir = new VECTOR3; - *es->ldir = (spec->ldir ? *spec->ldir : _V(0,0,1)); + *es->ldir = (spec->ldir ? *spec->ldir : VECTOR3{0,0,1}); es->flags |= EXHAUST_CONSTANTDIR; } @@ -3713,8 +3713,8 @@ double Vessel::MaxAngularMoment (int axis) const supervessel->GetCG (this, vcg); const ThrustGroupSpec *tgs = &m_thrusterGroupDef[THGROUP_ATT_PITCHUP+axis]; for (auto it = tgs->ts.begin(); it != tgs->ts.end(); it++) - M += crossp ((*it)->dir * (*it)->maxth0, (*it)->ref-MakeVECTOR3(vcg)); - return length (M); + M += cross((*it)->dir * (*it)->maxth0, (*it)->ref-MakeVECTOR3(vcg)); + return len(M); } // ======================================================================= @@ -5553,10 +5553,10 @@ bool Vessel::VCRedrawEvent (int id, int event, SURFHANDLE surf) const bool Vessel::VCMouseEvent (int id, int event, Vector &p) const { - if (modIntf.v && modIntf.v->Version() >= 1) { - VECTOR3 v = _V(p.x,p.y,p.z); - return ((VESSEL2*)modIntf.v)->clbkVCMouseEvent (id, event, v); - } + if (modIntf.v && modIntf.v->Version() >= 1) { + VECTOR3 v{p.x,p.y,p.z}; + return ((VESSEL2*)modIntf.v)->clbkVCMouseEvent (id, event, v); + } else return false; } @@ -5919,8 +5919,8 @@ bool Vessel::Read (ifstream &scn) //vs.xpdr = 0; //vs.nfuel = vs.nthruster = vs.ndockinfo = 0; //vs.surf_lng = vs.surf_lat = vs.surf_hdg = 0.0; - //veccpy (vs.vrot, _V(0,0,0)); - //veccpy (vs.arot, _V(0,0,0)); + //veccpy (vs.vrot, {0,0,0}); + //veccpy (vs.arot, {0,0,0}); void *vsptr = (void*)&vs; if (modIntf.v->Version() >= 1) { @@ -6655,7 +6655,7 @@ double VESSEL::GetSurfaceElevation () const VECTOR3 VESSEL::GetSurfaceNormal () const { const SurfParam *sp = vessel->GetSurfParam(); - return sp ? _V(sp->surfnml.x, sp->surfnml.y, sp->surfnml.z): _V(0,0,0); + return sp ? VECTOR3{sp->surfnml.x, sp->surfnml.y, sp->surfnml.z}: VECTOR3{0,0,0}; } double VESSEL::GetLift (void) const @@ -7755,14 +7755,14 @@ void VESSEL::HorizonRot (const VECTOR3 &rloc, VECTOR3 &rhorizon) const { if (!vessel->proxyplanet) return; Vector h (mul (vessel->sp.L2H, tmul (vessel->proxyplanet->GRot(), mul (vessel->GRot(), MakeVector(rloc))))); - rhorizon = _V(h.x, h.y, h.z); + rhorizon = {h.x, h.y, h.z}; } void VESSEL::HorizonInvRot (const VECTOR3 &rhorizon, VECTOR3 &rloc) const { if (!vessel->proxyplanet) return; Vector r (tmul (vessel->GRot(), mul (vessel->proxyplanet->GRot(), tmul (vessel->sp.L2H, MakeVector (rhorizon))))); - rloc = _V(r.x, r.y, r.z); + rloc = {r.x, r.y, r.z}; } void VESSEL::Local2Global (const VECTOR3 &local, VECTOR3 &global) const @@ -7861,7 +7861,7 @@ SUPERVESSELHANDLE VESSEL::GetSupervessel () const VECTOR3 VESSEL::GetSupervesselCG () const { - VECTOR3 cg = _V(0,0,0); + VECTOR3 cg{0,0,0}; if (vessel->supervessel) { Vector vcg; if (vessel->supervessel->GetCG (vessel, vcg)) @@ -8711,7 +8711,7 @@ int VESSEL2::clbkConsumeBufferedKey (DWORD key, bool down, char *keystate) bool VESSEL2::clbkLoadGenericCockpit () { - SetCameraDefaultDirection (_V(0,0,1)); + SetCameraDefaultDirection ({0,0,1}); return true; } @@ -8818,7 +8818,7 @@ void VESSEL3::clbkGetRadiationForce (const VECTOR3 &mflux, VECTOR3 &F, VECTOR3 & double albedo = 1.5; // simplistic albedo (mixture of absorption, reflection) F = mflux * (cs*albedo); - pos = _V(0,0,0); // don't induce torque + pos = {0,0,0}; // don't induce torque } @@ -8850,4 +8850,4 @@ bool VESSEL4::UnregisterMFDMode (int mode) int VESSEL4::clbkNavProcess (int mode) { return mode; -} +} diff --git a/Src/Orbiter/Vesselstatus.cpp b/Src/Orbiter/Vesselstatus.cpp index 30bd0a85b..b17c92dc3 100644 --- a/Src/Orbiter/Vesselstatus.cpp +++ b/Src/Orbiter/Vesselstatus.cpp @@ -665,9 +665,9 @@ void Vessel::GetState2 (void *status) vs->port = nport; Vector dp (GPos() - cbody->GPos()); Vector dv (GVel() - cbody->GVel()); - vs->rpos = _V(dp.x, dp.y, dp.z); - vs->rvel = _V(dv.x, dv.y, dv.z); - vs->vrot = (fstatus == FLIGHTSTATUS_LANDED ? _V(sp.alt, 0, 0) : _V(s0->omega.x, s0->omega.y, s0->omega.z)); + vs->rpos = {dp.x, dp.y, dp.z}; + vs->rvel = {dv.x, dv.y, dv.z}; + vs->vrot = (fstatus == FLIGHTSTATUS_LANDED ? VECTOR3{sp.alt, 0, 0} : VECTOR3{s0->omega.x, s0->omega.y, s0->omega.z}); EulerAngles (fstatus == FLIGHTSTATUS_LANDED ? land_rot : s0->R, vs->arot); vs->surf_lng = sp.lng; vs->surf_lat = sp.lat; diff --git a/Src/Orbiter/Vobject.h b/Src/Orbiter/Vobject.h index 8105f07e0..bd3ac3e4e 100644 --- a/Src/Orbiter/Vobject.h +++ b/Src/Orbiter/Vobject.h @@ -30,7 +30,7 @@ class VObject { static void CreateDeviceObjects (OrbiterGraphics *gclient); static void DestroyDeviceObjects (); - static D3DCOLORVALUE ColorToD3D(Vector4 col) { return { (float)col.x, (float)col.y, (float)col.z, (float)col.w }; }; + static D3DCOLORVALUE ColorToD3D(VECTOR4 col) { return { (float)col.x, (float)col.y, (float)col.z, (float)col.w }; }; virtual unsigned long GetCaps () const { return 0; } diff --git a/Src/Orbiter/Vvessel.cpp b/Src/Orbiter/Vvessel.cpp index e1c5cbf62..3d06d3a45 100644 --- a/Src/Orbiter/Vvessel.cpp +++ b/Src/Orbiter/Vvessel.cpp @@ -494,8 +494,8 @@ void SetExhaustVertices (const VECTOR3 &edir, const VECTOR3 &cdir, const VECTOR3 { // need to rotate the billboard so it faces the observer const float flarescale = 7.0; - VECTOR3 sdir = unit (crossp (cdir, edir)); - VECTOR3 tdir = unit (crossp (cdir, sdir)); + VECTOR3 sdir = unit(cross(cdir, edir)); + VECTOR3 tdir = unit(cross(cdir, sdir)); D3DVALUE rx = (D3DVALUE)ref.x, ry = (D3DVALUE)ref.y, rz = (D3DVALUE)ref.z; if (lofs) rx += (D3DVALUE)(edir.x*lofs), ry += (D3DVALUE)(edir.y*lofs), rz += (D3DVALUE)(edir.z*lofs); D3DVALUE sx = (D3DVALUE)(sdir.x*wscale); @@ -529,8 +529,8 @@ void SetReentryVertices (const VECTOR3 &edir, const VECTOR3 &cdir, const VECTOR3 const float flarescale = 1.0; const float lscale1 = (float)(lscale*llen * (1.0 + 0.1*rand()/(double)RAND_MAX)); const float lscale2 = (float)(lscale * 0.125); - VECTOR3 sdir = unit (crossp (cdir, edir)); - VECTOR3 tdir = unit (crossp (cdir, sdir)); + VECTOR3 sdir = unit(cross(cdir, edir)); + VECTOR3 tdir = unit(cross(cdir, sdir)); D3DVALUE rx = (D3DVALUE)ref.x, ry = (D3DVALUE)ref.y, rz = (D3DVALUE)ref.z; D3DVALUE sx = (D3DVALUE)(sdir.x*wscale); D3DVALUE sy = (D3DVALUE)(sdir.y*wscale); diff --git a/Src/Plugin/ScnEditor/Editor.cpp b/Src/Plugin/ScnEditor/Editor.cpp index 74a7f6bd3..88725d5a5 100644 --- a/Src/Plugin/ScnEditor/Editor.cpp +++ b/Src/Plugin/ScnEditor/Editor.cpp @@ -279,8 +279,8 @@ bool ScnEditor::CreateVessel (char *name, char *classname) if (!vs.rbody) vs.rbody = oapiGetGbodyByIndex (0); double rad = 1.1 * oapiGetSize (vs.rbody); double vel = sqrt (GGRAV * oapiGetMass (vs.rbody) / rad); - vs.rpos = _V(rad,0,0); - vs.rvel = _V(0,0,vel); + vs.rpos = {rad,0,0}; + vs.rvel = {0,0,vel}; // create the vessel OBJHANDLE newvessel = oapiCreateVesselEx (name, classname, &vs); if (!newvessel) return false; // failure @@ -2039,8 +2039,8 @@ void EditorTab_Statevec::Apply () needrefresh = true; } #endif - veccpy (vs.rpos, pos); - veccpy (vs.rvel, vel); + vs.rpos = pos; + vs.rvel = vel; vessel->DefSetState (&vs); if (needrefresh) Refresh(); } @@ -2236,7 +2236,7 @@ void EditorTab_Landed::Refresh (OBJHANDLE hV) oapiGetRelativePos (ed->hVessel, hRef, &pos); oapiGetRotationMatrix (hRef, &rot); pos = tmul (rot, pos); - VECTOR3 vel = _V(0,0,0); + VECTOR3 vel{0, 0, 0}; Crt2Pol (pos, vel); sprintf (lngstr, "%lf", pos.data[1] * DEG); sprintf (latstr, "%lf", pos.data[2] * DEG); diff --git a/Src/Plugin/TransX/BodyProvider.cpp b/Src/Plugin/TransX/BodyProvider.cpp index c6d397684..cbfe7fd7a 100644 --- a/Src/Plugin/TransX/BodyProvider.cpp +++ b/Src/Plugin/TransX/BodyProvider.cpp @@ -87,7 +87,7 @@ void BodyProvider::InitialiseSolarSystem() VECTOR3 pos; oapiGetRelativePos(body->bodyhandle, (*it)->bodyhandle, &pos); - double distance2 = dotp(pos, pos); + double distance2 = dot(pos, pos); if(distance2 < (*it)->soisize2) { currparent = *it; diff --git a/Src/Plugin/TransX/basefunction.cpp b/Src/Plugin/TransX/basefunction.cpp index c71c93448..d1ef5c37e 100644 --- a/Src/Plugin/TransX/basefunction.cpp +++ b/Src/Plugin/TransX/basefunction.cpp @@ -630,7 +630,7 @@ void basefunction::calculate(VECTOR3 *targetvel) VECTOR3 pos,vel; oapiGetRelativeVel(hcraft,hmajor,&vel); oapiGetRelativePos(hcraft,hmajor,&pos); - double distance=length(pos); + double distance = len(pos); double velenergy=length2my(vel)*0.5; double overallenergy=-GRAVITY*oapiGetMass(hmajor)/distance+velenergy; craft.init(hmajor, hcraft); @@ -928,14 +928,14 @@ void basefunction::doupdate(oapi::Sketchpad *sketchpad,int tw, int th,int viewmo //Describe targeting quality int hpos=8*linespacing; int wpos=0; - double closestApp = length(craftpos-targetpos); + double closestApp = len(craftpos-targetpos); TextShow(sketchpad, "Cl. App.: ", wpos, hpos, closestApp); hpos+=linespacing; TextShow(sketchpad, "Hohmann dv: ", wpos, hpos, GetHohmannDV()); hpos+=linespacing; VECTOR3 relvel; primary.getrelvel(&relvel); - TextShow(sketchpad,"Enc. V:", wpos, hpos, length(relvel)); + TextShow(sketchpad,"Enc. V:", wpos, hpos, len(relvel)); hpos+=linespacing; double intercepttime=primary.gettimeintercept(); double arrmjd=oapiTime2MJD(intercepttime); @@ -999,7 +999,7 @@ void basefunction::Getmode2hypo(VECTOR3 *targetvel) //basisorbit.timetovectors(difftime, &ejradius, &ejvel); VECTOR3 forward=unit(ejvel)*m_prograde; - VECTOR3 outward=unit(crossp(ejvel, basisorbit.getplanevector()))*m_outwardvel; + VECTOR3 outward = unit(cross(ejvel, basisorbit.getplanevector())) * m_outwardvel; VECTOR3 sideward=unit(basisorbit.getplanevector())*m_chplvel; VECTOR3 ejectvector=forward+outward+sideward; //=Eject vector in basisorbit frame @@ -1043,8 +1043,8 @@ double basefunction::GetHohmannDV() VECTOR3 posSrc, posTgt; oapiGetRelativePos(currentMinor, hmajor, &posSrc); oapiGetRelativePos(hmajtarget, hmajor, &posTgt); - double radSrc = length(posSrc); - double radTgt = length(posTgt); + double radSrc = len(posSrc); + double radTgt = len(posTgt); double dv = GetHohmannDVExtend(radSrc, radTgt, oapiGetMass(hmajor)); if (radTgt > radSrc) return dv; @@ -1057,18 +1057,16 @@ VECTOR3 basefunction::GetPlaneAxis(const OBJHANDLE hObj, const OBJHANDLE hRef) VECTOR3 pos, vel; oapiGetRelativePos(hObj, hRef, &pos); oapiGetRelativeVel(hObj, hRef, &vel); - const VECTOR3& axis = crossp(pos, vel); - return axis; + return cross(pos, vel); } VECTOR3 basefunction::GetLineOfNodes() { OBJHANDLE currentMinor = hminor ? hminor : oapiGetFocusObject(); // Eject or Manoeuvre? - if (!currentMinor || !hmajor || !hmajtarget) - return _V(0,0,0); - const VECTOR3 & planeMinor = GetPlaneAxis(currentMinor, hmajor); - const VECTOR3 & planeMajor = GetPlaneAxis(hmajtarget, hmajor); - const VECTOR3 & lineOfNodes = crossp(planeMinor, planeMajor); - return lineOfNodes; + if (!currentMinor || !hmajor || !hmajtarget) return {0, 0, 0}; + + auto planeMinor = GetPlaneAxis(currentMinor, hmajor); + auto planeMajor = GetPlaneAxis(hmajtarget, hmajor); + return cross(planeMinor, planeMajor); } diff --git a/Src/Plugin/TransX/globals.cpp b/Src/Plugin/TransX/globals.cpp index 6798b2759..ad01df227 100644 --- a/Src/Plugin/TransX/globals.cpp +++ b/Src/Plugin/TransX/globals.cpp @@ -215,7 +215,7 @@ double length2my(const VECTOR3 &v) double cosangle(const VECTOR3 &veca,const VECTOR3 &vecb) { - return dotp(veca,vecb)/sqrt(length2my(veca)*length2my(vecb)); + return dot(veca, vecb) / sqrt(length2my(veca) * length2my(vecb)); } void getinvrotmatrix(VECTOR3 arot, MATRIX3 *invrotmatrix)//arot not really a vector - see arot defn from vessel struct diff --git a/Src/Plugin/TransX/graph.cpp b/Src/Plugin/TransX/graph.cpp index 178800a3c..3711bbe9f 100644 --- a/Src/Plugin/TransX/graph.cpp +++ b/Src/Plugin/TransX/graph.cpp @@ -114,8 +114,8 @@ void Graph::setprojection(const VECTOR3 &projection) { VECTOR3 temp={0,-1,0}; // Ecliptic vector zaxis=unit(projection); - VECTOR3 cross=unit(crossp(temp, zaxis)); // Vector of LAN x+z only - VECTOR3 xcross=crossp(cross, zaxis); //90 around - max out of plane + VECTOR3 cross = unit(::cross(temp, zaxis)); // Vector of LAN x+z only + VECTOR3 xcross = ::cross(cross, zaxis); // 90 around - max out of plane xaxis=cross*cross.x+xcross*cross.z; // Back around the orbit yaxis=xcross*cross.x-cross*cross.z; } @@ -136,14 +136,14 @@ void Graph::drawtwovector(oapi::Sketchpad *sketchpad, const VECTOR3 &line1, cons xpos=int(xoffset); ypos=int(yoffset); sketchpad->MoveTo(xpos, ypos); - xpos=int(dotp(xaxis, line1)*scale+xoffset); - ypos=int(dotp(yaxis, line1)*scale+yoffset); + xpos = int(dot(xaxis, line1) * scale + xoffset); + ypos = int(dot(yaxis, line1) * scale + yoffset); sketchpad->LineTo(xpos, ypos); xpos=int(xoffset); ypos=int(yoffset); sketchpad->MoveTo(xpos, ypos); - xpos=int(dotp(xaxis, line2)*scale+xoffset); - ypos=int(dotp(yaxis, line2)*scale+yoffset); + xpos = int(dot(xaxis, line2) * scale + xoffset); + ypos = int(dot(yaxis, line2) * scale + yoffset); sketchpad->LineTo(xpos, ypos); } @@ -156,8 +156,8 @@ void Graph::drawvector(oapi::Sketchpad *sketchpad,const VECTOR3 &line1) xpos=int(xoffset); ypos=int(yoffset); sketchpad->MoveTo(xpos, ypos); - xpos=int(dotp(xaxis, line1)*scale+xoffset); - ypos=int(dotp(yaxis, line1)*scale+yoffset); + xpos = int(dot(xaxis, line1) * scale + xoffset); + ypos = int(dot(yaxis, line1) * scale + yoffset); sketchpad->LineTo(xpos, ypos); } @@ -169,8 +169,8 @@ void Graph::drawvectorline(oapi::Sketchpad *sketchpad, const VECTOR3 &line) const double yoffset=(iystart+iyend)*0.5; int xpos, ypos; VECTOR3 temp=unit(line)*(windowsize/2); - double xline=dotp(xaxis, temp); - double yline=dotp(yaxis, temp); + double xline = dot(xaxis, temp); + double yline = dot(yaxis, temp); xpos=int(xoffset-xline); ypos=int(yoffset-yline); sketchpad->MoveTo(xpos, ypos); @@ -285,7 +285,7 @@ double Graph::vectorpointdisplay(oapi::Sketchpad *sketchpad, const VECTOR3 &targ sketchpad->LineTo(xpos + crossSize, ypos + crossSize); sketchpad->MoveTo(xpos - crossSize, ypos + crossSize); sketchpad->LineTo(xpos + crossSize, ypos - crossSize); - return length(trtarget); + return len(trtarget); } void Graph::drawmarker(oapi::Sketchpad *sketchpad, const VECTOR3 & location, Shape shape) @@ -294,8 +294,8 @@ void Graph::drawmarker(oapi::Sketchpad *sketchpad, const VECTOR3 & location, Sha int y = (iystart + iyend) / 2; const int radius = 3; - double xpos = dotp(xaxis, location) * scale; - double ypos = dotp(yaxis, location) * scale; + double xpos = dot(xaxis, location) * scale; + double ypos = dot(yaxis, location) * scale; int left = (int)(x + xpos - radius + 0.5); // add 0.5 to round off rather than floor int right = (int)(x + xpos + radius + 0.5); int top = (int)(y + ypos - radius + 0.5); diff --git a/Src/Plugin/TransX/intercept.cpp b/Src/Plugin/TransX/intercept.cpp index c98f678ce..d00e14b6e 100644 --- a/Src/Plugin/TransX/intercept.cpp +++ b/Src/Plugin/TransX/intercept.cpp @@ -138,7 +138,7 @@ void Intercept::improveinterceptstraightline(const OrbitElements &craft, const O //Now use dotp to estimate remaining course correction VECTOR3 relcraftpos=icraftpos-itargetpos; VECTOR3 relcraftvel=icraftvel-itargetvel; - double timecorrection=-dotp(relcraftpos,relcraftvel)/dotp(relcraftvel,relcraftvel); + double timecorrection = -dot(relcraftpos, relcraftvel) / dot(relcraftvel, relcraftvel); if (timecorrection*lasttimecorrection<0 && fabs(timecorrection/orbittime)>0.0001) {//Oscillatory gain=gain*0.5; @@ -158,7 +158,7 @@ void Intercept::improveinterceptstraightline(const OrbitElements &craft, const O icepttimeoffset=crafttimeest+timecorrection*gain; itimeintercept=icepttimeoffset+target.gettimestamp(); - if (length(relcraftpos)*3>length(icraftpos))//Allows method to switch back if solution is no longer good + if (len(relcraftpos) * 3 > len(icraftpos)) //Allows method to switch back if solution is no longer good { iceptmethod=1; } @@ -178,7 +178,7 @@ void Intercept::updateintercept(const OrbitElements &craft, const OrbitElements { if (!craft.isvalid() || !target.isvalid()) return;//Ensure no void updates! double timeoffset=craft.gettimestamp()-target.gettimestamp(); - iplanecept=crossp(craft.getplanevector(),target.getplanevector()); + iplanecept = cross(craft.getplanevector(), target.getplanevector()); if (iceptmethod==2) { improveinterceptstraightline(craft,target); @@ -268,7 +268,7 @@ void Intercept::updateintercept(const OrbitElements &craft, const OrbitElements if (abetter) { //a is better - iceptradius=(length(betaposa)+iceptradius)/2;// Takes average of new and old as this converges better + iceptradius = (len(betaposa) + iceptradius) / 2;// Takes average of new and old as this converges better itimeintercept=timea; if (length2my(betaposa-alphaposa)*9gravbodyratio2); + radius = sqrt(dot(vecradius, vecradius) * body->gravbodyratio2); } return radius; } diff --git a/Src/Plugin/TransX/orbitelements.cpp b/Src/Plugin/TransX/orbitelements.cpp index 62eb53bb5..d983680cf 100644 --- a/Src/Plugin/TransX/orbitelements.cpp +++ b/Src/Plugin/TransX/orbitelements.cpp @@ -131,9 +131,9 @@ void OrbitElements::majortominorinit(OBJHANDLE target, OBJHANDLE object, const I closestapproach.getrelvel(&minorvel); //First use dotp to get to closest approach exactly - double minorvelsize=length(minorvel); - double firsttime=dotp(minorpos,minorvel)/(minorvelsize*minorvelsize);//Small correction - not the problem, though - minorpos=minorpos-minorvel*(dotp(minorpos,minorvel)/minorvelsize); + double minorvelsize = len(minorvel); + double firsttime = dot(minorpos, minorvel) / (minorvelsize * minorvelsize); //Small correction - not the problem, though + minorpos=minorpos - minorvel * (dot(minorpos, minorvel) / minorvelsize); //Now precisely at closest approach //Now use pythagoras to find required length back to 10xSOI double backradius=100*soisize*soisize; @@ -144,7 +144,7 @@ void OrbitElements::majortominorinit(OBJHANDLE target, OBJHANDLE object, const I oapiGetRelativePos(object, target,&currvector); double actdistance2=length2my(currvector); if (actdistance2 0 ? sqrt(backradius) : 0; double timeoffset=backradius/minorvelsize-firsttime; @@ -175,7 +175,7 @@ void OrbitElements::radiustovectors(double radius, bool outward, VECTOR3 *positi if (!outward) sinthi=-sinthi; *position=majoraxis*(radius*costhi)+minoraxis*(radius*sinthi); VECTOR3 outvector=unit(*position); - VECTOR3 roundvector=unit(crossp(planevector, outvector)); + VECTOR3 roundvector=unit(cross(planevector, outvector)); double rndvel2=angularmomentum2/(radius*radius); double outvel=eccentricity*planet*sinthi/sqrt(angularmomentum2); *velocity=outvector*outvel+roundvector*sqrt(rndvel2); @@ -254,23 +254,23 @@ void OrbitElements::init(const VECTOR3 &rposition, const VECTOR3 &rvelocity, dou void OrbitElements::init(const VECTOR3 &rposition, const VECTOR3 &rvelocity, double ttimestamp, double gmplanet) { VECTOR3 *ptr = const_cast(&rvelocity); - if(length(rvelocity) < 0.00000001) + if(len(rvelocity) < 0.00000001) ptr->x = 0.00000000001; // If it is zero, it causes problems, so make it very small. valid=true; - planevector=crossp(rposition,rvelocity); - angularmomentum2=dotp(planevector, planevector); //Angular momentum squared (don't usually need it non-squared) + planevector = cross(rposition, rvelocity); + angularmomentum2 = dot(planevector, planevector); //Angular momentum squared (don't usually need it non-squared) - double rvel2=dotp(rvelocity, rvelocity); - double radius=length(rposition); + double rvel2 = dot(rvelocity, rvelocity); + double radius = len(rposition); if (radius != 0) { - eccvector=(rposition*(rvel2-gmplanet/radius)-rvelocity*dotp(rposition, rvelocity))*(1/gmplanet); //Eccentricity vector + eccvector = (rposition * (rvel2 - gmplanet / radius) - rvelocity * dot(rposition, rvelocity)) * (1/gmplanet); //Eccentricity vector semimajor=gmplanet/(rvel2-2*gmplanet/radius); //Length of semimajor axis - is NEGATIVE if orbit is elliptical, POSITIVE if hyperbolic - eccentricity=length(eccvector); //Eccentricity of orbit + eccentricity = len(eccvector); //Eccentricity of orbit majoraxis=unit(eccvector); //Vector towards Periapsis - minoraxis=unit(crossp(planevector, majoraxis)); // Vector parallel to Minor axis of orbit - important for extracting vectors later - currcosthi=dotp(rposition, majoraxis)/radius; //cos thi is angle from periapsis, as measured from planet centre - currsinthi=dotp(rposition, minoraxis)/radius; + minoraxis = unit(cross(planevector, majoraxis)); // Vector parallel to Minor axis of orbit - important for extracting vectors later + currcosthi = dot(rposition, majoraxis) / radius; //cos thi is angle from periapsis, as measured from planet centre + currsinthi = dot(rposition, minoraxis) / radius; currposition=rposition; currvelocity=rvelocity; planet=gmplanet; @@ -518,8 +518,8 @@ double OrbitElements::GetTimeToThi(double costhi, double sinthi,int fullorbits,i void OrbitElements::vectortothi(const VECTOR3 &vector,double *costhi,double *sinthi) const { - double majorsize=dotp(vector,majoraxis); - double minorsize=dotp(vector,minoraxis); + double majorsize = dot(vector, majoraxis); + double minorsize = dot(vector, minoraxis); double scaling=sqrt(majorsize*majorsize+minorsize*minorsize); *costhi=majorsize/scaling; *sinthi=minorsize/scaling; @@ -553,12 +553,12 @@ double OrbitElements::getapodistance() const double OrbitElements::getcurrradius() const { - return length(currposition); + return len(currposition); } VECTOR3 OrbitElements::getintersectvector(const OrbitElements &torbit) const { - return crossp(planevector, torbit.planevector); + return cross(planevector, torbit.planevector); } double OrbitElements::geteccentricity() const @@ -741,8 +741,8 @@ void OrbitElements::draworbit(oapi::Sketchpad *sketchpad, const Graph *graph, bo { ct=0; currvector=majoraxis*(topconstant/(eccentricity+1)); - xposd= dotp(xaxis, currvector)*scale +xoffset; - yposd= dotp(yaxis, currvector)*scale +yoffset; + xposd = dot(xaxis, currvector) * scale + xoffset; + yposd = dot(yaxis, currvector) * scale + yoffset; if (xposdxend || yposdxend) return; // Makes safe if orbit too large to fit screen! xpos=int(xposd); ypos=int(yposd); @@ -764,8 +764,8 @@ void OrbitElements::draworbit(oapi::Sketchpad *sketchpad, const Graph *graph, bo } currentradius=topconstant/currdivisor; currvector=majoraxis*(currcos*currentradius)+minoraxis*(currentradius*currsin); - xposd=dotp(xaxis,currvector)*scale+xoffset; - yposd=dotp(yaxis,currvector)*scale+yoffset; + xposd = dot(xaxis, currvector) * scale + xoffset; + yposd = dot(yaxis, currvector) * scale + yoffset; // Following four if statements ensure proper truncation of line segments attempting to draw // beyond the boundaries of the MFD if (xposdMoveTo(xpos, ypos); currvector=currposition; - xpos= int(dotp(xaxis, currvector)*scale +xoffset); - ypos= int(dotp(yaxis, currvector)*scale +yoffset); + xpos = int(dot(xaxis, currvector) * scale + xoffset); + ypos = int(dot(yaxis, currvector) * scale + yoffset); sketchpad->LineTo(xpos, ypos); } } diff --git a/Src/Plugin/TransX/planfunction.cpp b/Src/Plugin/TransX/planfunction.cpp index d717c288a..0518b0741 100644 --- a/Src/Plugin/TransX/planfunction.cpp +++ b/Src/Plugin/TransX/planfunction.cpp @@ -127,7 +127,7 @@ void slingshot::calculate(class MFDvarhandler *vars,basefunction *base) return; } if (!craft.isvalid()) return; - inwardvelocity=length(inward); + inwardvelocity = len(inward); if (ejectvelocity2<1 || inwardvelocity<1) return; //We now have both vectors @@ -166,7 +166,7 @@ void slingshot::calculate(class MFDvarhandler *vars,basefunction *base) //set up coordinate system ratiotoradius=periapsisguess/oapiGetSize(hmajor); VECTOR3 asvel=inward*(1/inwardvelocity); - VECTOR3 rightangletovel=unit(asvel*dotp(asvel,ejectvector)-ejectvector); + VECTOR3 rightangletovel = unit(asvel * dot(asvel, ejectvector) - ejectvector); double cosfirst=sqrt(1-sinfirst*sinfirst); VECTOR3 peposition=(rightangletovel*cosfirst+asvel*sinfirst)*periapsisguess; VECTOR3 pevel=rightangletovel*(-sinfirst)+asvel*cosfirst; @@ -198,7 +198,7 @@ void minorejectplan::graphscale(Graph *graph) svelocity=unit(svelocity); //unit to give vector parallel to rotation oapiGetFocusRelativePos(hmajor,&craftpos); VECTOR3 tradius=unit(craftpos);//Get unit radius vector - VECTOR3 tvector=unit(crossp(tradius, svelocity)); + VECTOR3 tvector=unit(cross(tradius, svelocity)); double longitude, latitude, tnumber; oapiGetFocusEquPos(&longitude, &latitude, &tnumber);//Only works if current planet's surface dominates double cosl=cos(-latitude); @@ -247,9 +247,9 @@ bool slingshot::maingraph(oapi::Sketchpad *sketchpad,Graph *graph,basefunction * graph->setviewscalesize(planetsize); VECTOR3 planpos,craftpos,velvector; planorbit.thitovectors(1,0,&planpos,&velvector); - graph->setviewscalesize(length(planpos)); + graph->setviewscalesize(len(planpos)); craft.thitovectors(1,0,&craftpos,&velvector); - graph->setviewscalesize(length(craftpos)); + graph->setviewscalesize(len(craftpos)); craft.getinfinityvelvector(false,&velvector);//Now finally set for real graph->setprojection(velvector); @@ -344,7 +344,7 @@ void minorejectplan::wordupdate(oapi::Sketchpad *sketchpad, int width, int heigh pos += linespacing; // Get the target LAN (absolute wrt global coordinates) - VECTOR3 LAN = crossp(planorbit.getplanevector(), down); + VECTOR3 LAN = cross(planorbit.getplanevector(), down); double lan = atan2(LAN.z, LAN.x) * 180 / PI; if(lan < 0) lan += 360; @@ -356,7 +356,7 @@ void minorejectplan::wordupdate(oapi::Sketchpad *sketchpad, int width, int heigh { //Vessel is landed! VECTOR3 tintersectvector=planorbit.getintersectvector(craft);//Gets intersection vector tpos=status.rpos; - if (dotp(tintersectvector,tpos)<0) + if (dot(tintersectvector, tpos) < 0) angle+=90; else angle=90-angle; @@ -379,8 +379,8 @@ void minorejectplan::wordupdate(oapi::Sketchpad *sketchpad, int width, int heigh // Calculate Delta-v if (status.rbody!=base->gethmajor()) return; //if (craft.getpedistance()GetTimeIntercept() - m_ejdate; TextShow(sketchpad,"TOF (days):",wpos,22*linespacing,numDays); - double totaldv=length(ejectvector); + double totaldv = len(ejectvector); if (totaldv>0.1) { //bottom right, watch both glass cockpit AND panel view for correct placement. @@ -644,7 +644,7 @@ bool majorejectplan::init(class MFDvarhandler *vars, class basefunction *base) void majorejectplan::calcejectvector(const VECTOR3 &rminplane,const VECTOR3 &minorvel, double inheritedvelocity) {//Final param not used here VECTOR3 forward=unit(minorvel)*m_prograde; - VECTOR3 outward=unit(crossp(minorvel, rminplane))*m_outwardvel; + VECTOR3 outward=unit(cross(minorvel, rminplane))*m_outwardvel; VECTOR3 sideward=unit(rminplane)*m_chplvel; ejectvector=forward+outward+sideward; //=Eject vector in RMin frame } @@ -652,7 +652,7 @@ void majorejectplan::calcejectvector(const VECTOR3 &rminplane,const VECTOR3 &min void slingejectplan::calcejectvector(const VECTOR3 &rminplane,const VECTOR3 &minorvel, double inheritedvelocity) { VECTOR3 forward=unit(minorvel)*m_outwardangle.getcos()*m_incangle.getcos(); - VECTOR3 outward=unit(crossp(minorvel,rminplane))*m_outwardangle.getsin()*m_incangle.getcos(); + VECTOR3 outward=unit(cross(minorvel,rminplane))*m_outwardangle.getsin()*m_incangle.getcos(); VECTOR3 sideward=unit(rminplane)*m_incangle.getsin(); ejectvector=forward+outward+sideward; if (m_inheritvel==0 && inheritedvelocity>0) @@ -762,7 +762,7 @@ void minorejectplan::calculate(class MFDvarhandler *vars,basefunction *base) { ejectvector=nextplan->getvelocityvector(); ejecttime=nextplan->geteventtime(); - ejectvelocity2=dotp(ejectvector,ejectvector); + ejectvelocity2 = dot(ejectvector, ejectvector); } } else @@ -778,8 +778,8 @@ void minorejectplan::calculate(class MFDvarhandler *vars,basefunction *base) //Set up temporary coordinate system VECTOR3 rminplane=(base->getcontextorbit()).getplanevector(); VECTOR3 txaxis=unit(ejectvector); - VECTOR3 tzaxis=unit(crossp(ejectvector, rminplane)); - VECTOR3 tyaxis=unit(crossp(ejectvector, tzaxis)); + VECTOR3 tzaxis=unit(cross(ejectvector, rminplane)); + VECTOR3 tyaxis=unit(cross(ejectvector, tzaxis)); double ejorientsinvalue = m_ejorient.getsin(); double ejorientcosvalue = m_ejorient.getcos(); VECTOR3 tnaxis=tzaxis*ejorientcosvalue+tyaxis*ejorientsinvalue; diff --git a/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp b/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp index 876436301..a8aa83f71 100644 --- a/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp +++ b/Src/Vessel/Atlantis/Atlantis/AscentAP.cpp @@ -275,22 +275,22 @@ void AscentAP::SetLaunchAzimuth (double azimuth) oapiGlobalToLocal (hRef, &pos, &equ); oapiLocalToEqu (hRef, equ, &lng, &lat, &rad); slng = sin(lng), clng = cos(lng), slat = sin(lat), clat = cos(lat); - normalise(equ); // unit radius vector + equ = unit(equ); // unit radius vector // launch direction in local planet frame - dir = _V(-clng*slat*caz - slng*saz, clat*caz, -slng*slat*caz + clng*saz); + dir = {-clng*slat*caz - slng*saz, clat*caz, -slng*slat*caz + clng*saz}; // normal of orbital plane in local planet frame - nml = crossp(dir, equ); + nml = cross(dir, equ); // normal of equator plane in local planet frame - ne = _V(0,1,0); + ne = {0,1,0}; // direction of ascending node - nd = unit (crossp(nml, ne)); + nd = unit(cross(nml, ne)); // orbit inclination - tgt.inc = acos(dotp(nml, ne)); + tgt.inc = std::acos(dot(nml, ne)); // longitude of ascending node tgt.lan = atan2(nd.z, nd.x); @@ -315,10 +315,10 @@ double AscentAP::CalcTargetAzimuth () const oapiGetRotationMatrix (hRef, &pR); vessel->GetGlobalPos(pos); oapiGlobalToLocal (hRef, &pos, &equ); // vessel position in planet frame - normalise(equ); + equ = unit(equ); ep = tmul(tgt.R,equ); // rotate to equator plane double elng = atan2(ep.z, ep.x); // longitude of rotated position - dir = _V(-sin(elng),0,cos(elng)); // rotated target direction + dir = {-sin(elng),0,cos(elng)}; // rotated target direction dir = mul(tgt.R,dir); // target direction in planet frame dir = mul(pR, dir); // target direction in global frame vessel->GetRotationMatrix (vR); @@ -402,7 +402,7 @@ void AscentAP::GetTargetDirection (double met, VECTOR3 &dir, double &tgt_hdg) co double tgt_pitch = tgt.pitch; double xz = cos(tgt_pitch); - vessel->HorizonInvRot(_V(xz*sin(tgt_hdg), sin(tgt_pitch), xz*cos(tgt_hdg)), dir); + vessel->HorizonInvRot({xz*sin(tgt_hdg), sin(tgt_pitch), xz*cos(tgt_hdg)}, dir); } // -------------------------------------------------------------- @@ -482,7 +482,7 @@ double AscentAP::GetTargetRollRate (double tgt, bool tgt_is_heading) const double dh, droll = avel.z; if (tgt_is_heading) { - vessel->HorizonRot (_V(0,1,0), yh); + vessel->HorizonRot ({0,1,0}, yh); double yhdg = atan2(yh.x, yh.z); dh = yhdg-tgt; if (dh > PI) dh -= PI2; diff --git a/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp b/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp index 46a94a8cb..595afb44c 100644 --- a/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp +++ b/Src/Vessel/Atlantis/Atlantis/Atlantis.cpp @@ -86,7 +86,7 @@ Atlantis::Atlantis (OBJHANDLE hObj, int fmodel) engine_light_level = 0.0; COLOUR4 col_diff = {1,0.8,0.8,0}; COLOUR4 col_zero = {0,0,0,0}; - engine_light = AddPointLight (_V(0,0,-25), 300, 2e-4, 0, 4e-4, col_diff, col_zero, col_zero); + engine_light = AddPointLight ({0,0,-25}, 300, 2e-4, 0, 4e-4, col_diff, col_zero, col_zero); engine_light->SetIntensityRef (&engine_light_level); LoadMeshes(); @@ -111,19 +111,19 @@ Atlantis::Atlantis (OBJHANDLE hObj, int fmodel) // Aerodynamics CreateAirfoils(); - CreateDock (ORBITER_DOCKPOS, _V(0,1,0), _V(0,0,-1)); - hDockET = CreateDock (_V(0.0,-2.48, 8.615), _V(0,-1,0), _V(0,0,1)); + CreateDock (ORBITER_DOCKPOS, {0,1,0}, {0,0,-1}); + hDockET = CreateDock ({0.0,-2.48, 8.615}, {0,-1,0}, {0,0,1}); pET = NULL; // ET reference center_arm = false; arm_moved = arm_scheduled = false; bManualSeparate = false; - ofs_sts_sat = _V(0,0,0); + ofs_sts_sat = {0,0,0}; do_eva = false; do_plat = false; do_cargostatic = false; vis = NULL; - cargo_static_ofs =_V(0,0,0); + cargo_static_ofs ={0,0,0}; // default arm status: stowed arm_sy = 0.5; @@ -132,11 +132,11 @@ Atlantis::Atlantis (OBJHANDLE hObj, int fmodel) arm_wp = 0.5; arm_wy = 0.5; arm_wr = 0.5; - arm_tip[0] = _V(-2.26,1.71,-6.5); - arm_tip[1] = _V(-2.26,1.71,-7.5); - arm_tip[2] = _V(-2.26,2.71,-6.5); + arm_tip[0] = {-2.26,1.71,-6.5}; + arm_tip[1] = {-2.26,1.71,-7.5}; + arm_tip[2] = {-2.26,2.71,-6.5}; - sat_attach = CreateAttachment (false, ofs_sts_sat, _V(0,1,0), _V(0,0,1), "X"); + sat_attach = CreateAttachment (false, ofs_sts_sat, {0,1,0}, {0,0,1}, "X"); rms_attach = CreateAttachment (false, arm_tip[0], arm_tip[1]-arm_tip[0], arm_tip[2]-arm_tip[0], "G", true); // Entry particle stream @@ -234,105 +234,105 @@ void Atlantis::CreateRCS() // set of attitude thrusters (idealised). The arrangement is such that no angular // momentum is created in linear mode, and no linear momentum is created in rotational mode. THRUSTER_HANDLE th_att_rot[4], th_att_lin[4]; - th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 15.5), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[1] = th_att_lin[3] = CreateThruster (_V(0,0,-15.5), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[2] = th_att_lin[2] = CreateThruster (_V(0,0, 15.5), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-15.5), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[0] = th_att_lin[0] = CreateThruster ({0,0, 15.5}, {0, 1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[1] = th_att_lin[3] = CreateThruster ({0,0,-15.5}, {0,-1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[2] = th_att_lin[2] = CreateThruster ({0,0, 15.5}, {0,-1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[3] = th_att_lin[1] = CreateThruster ({0,0,-15.5}, {0, 1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_PITCHUP); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_PITCHDOWN); CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_UP); CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_DOWN); - AddExhaust (th_att_rot[0], eh, ew1, _V( 1.60,-0.20, 18.78), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F2D - AddExhaust (th_att_rot[0], eh, ew1, _V( 1.68,-0.18, 18.40), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F4D - AddExhaust (th_att_rot[0], eh, ew1, _V(-1.55,-0.20, 18.78), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F1D - AddExhaust (th_att_rot[0], eh, ew1, _V(-1.63,-0.18, 18.40), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F3D + AddExhaust (th_att_rot[0], eh, ew1, { 1.60,-0.20, 18.78}, { 0.4339,-0.8830,-0.1793}, tex_rcs);//F2D + AddExhaust (th_att_rot[0], eh, ew1, { 1.68,-0.18, 18.40}, { 0.4339,-0.8830,-0.1793}, tex_rcs);//F4D + AddExhaust (th_att_rot[0], eh, ew1, {-1.55,-0.20, 18.78}, {-0.4339,-0.8830,-0.1793}, tex_rcs);//F1D + AddExhaust (th_att_rot[0], eh, ew1, {-1.63,-0.18, 18.40}, {-0.4339,-0.8830,-0.1793}, tex_rcs);//F3D - AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.30), _V(0, 1,0), tex_rcs);//L4U - AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.70), _V(0, 1,0), tex_rcs);//L2U - AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-13.10), _V(0, 1,0), tex_rcs);//L1U + AddExhaust (th_att_rot[1], eh, ew1, {-3.46, 3.20,-12.30}, {0, 1,0}, tex_rcs);//L4U + AddExhaust (th_att_rot[1], eh, ew1, {-3.46, 3.20,-12.70}, {0, 1,0}, tex_rcs);//L2U + AddExhaust (th_att_rot[1], eh, ew1, {-3.46, 3.20,-13.10}, {0, 1,0}, tex_rcs);//L1U - AddExhaust (th_att_rot[1], eh, ew1, _V( 3.43, 3.20,-12.30), _V(0, 1,0), tex_rcs);//R4U - AddExhaust (th_att_rot[1], eh, ew1, _V( 3.43, 3.20,-12.70), _V(0, 1,0), tex_rcs);//R2U - AddExhaust (th_att_rot[1], eh, ew1, _V( 3.43, 3.20,-13.10), _V(0, 1,0), tex_rcs);//R1U + AddExhaust (th_att_rot[1], eh, ew1, { 3.43, 3.20,-12.30}, {0, 1,0}, tex_rcs);//R4U + AddExhaust (th_att_rot[1], eh, ew1, { 3.43, 3.20,-12.70}, {0, 1,0}, tex_rcs);//R2U + AddExhaust (th_att_rot[1], eh, ew1, { 3.43, 3.20,-13.10}, {0, 1,0}, tex_rcs);//R1U - AddExhaust (th_att_rot[2], eh, ew1, _V(-0.4 , 1.10, 18.3 ), _V(0, 1,0), tex_rcs);//F1U - AddExhaust (th_att_rot[2], eh, ew1, _V( 0.0 , 1.15 ,18.3 ), _V(0, 1,0), tex_rcs);//F3U - AddExhaust (th_att_rot[2], eh, ew1, _V( 0.4 , 1.10, 18.3 ), _V(0, 1,0), tex_rcs);//F2U + AddExhaust (th_att_rot[2], eh, ew1, {-0.4 , 1.10, 18.3 }, {0, 1,0}, tex_rcs);//F1U + AddExhaust (th_att_rot[2], eh, ew1, { 0.0 , 1.15 ,18.3 }, {0, 1,0}, tex_rcs);//F3U + AddExhaust (th_att_rot[2], eh, ew1, { 0.4 , 1.10, 18.3 }, {0, 1,0}, tex_rcs);//F2U - AddExhaust (th_att_rot[3], eh, ew1, _V(-3.1 , 1.55,-12.45), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L4D - AddExhaust (th_att_rot[3], eh, ew1, _V(-3.1 , 1.6 ,-12.8 ), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L2D - AddExhaust (th_att_rot[3], eh, ew1, _V(-3.1 , 1.65,-13.15), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L3D + AddExhaust (th_att_rot[3], eh, ew1, {-3.1 , 1.55,-12.45}, {-0.2844,-0.9481,-0.1422}, tex_rcs);//L4D + AddExhaust (th_att_rot[3], eh, ew1, {-3.1 , 1.6 ,-12.8 }, {-0.2844,-0.9481,-0.1422}, tex_rcs);//L2D + AddExhaust (th_att_rot[3], eh, ew1, {-3.1 , 1.65,-13.15}, {-0.2844,-0.9481,-0.1422}, tex_rcs);//L3D - AddExhaust (th_att_rot[3], eh, ew1, _V( 3.15, 1.55,-12.45), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R4D - AddExhaust (th_att_rot[3], eh, ew1, _V( 3.15, 1.6 ,-12.8 ), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R2D - AddExhaust (th_att_rot[3], eh, ew1, _V( 3.15, 1.65,-13.15), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R3D + AddExhaust (th_att_rot[3], eh, ew1, { 3.15, 1.55,-12.45}, { 0.2844,-0.9481,-0.1422}, tex_rcs);//R4D + AddExhaust (th_att_rot[3], eh, ew1, { 3.15, 1.6 ,-12.8 }, { 0.2844,-0.9481,-0.1422}, tex_rcs);//R2D + AddExhaust (th_att_rot[3], eh, ew1, { 3.15, 1.65,-13.15}, { 0.2844,-0.9481,-0.1422}, tex_rcs);//R3D - th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 15.5), _V(-1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[1] = th_att_lin[3] = CreateThruster (_V(0,0,-15.5), _V( 1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[2] = th_att_lin[2] = CreateThruster (_V(0,0, 15.5), _V( 1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-15.5), _V(-1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[0] = th_att_lin[0] = CreateThruster ({0,0, 15.5}, {-1,0,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[1] = th_att_lin[3] = CreateThruster ({0,0,-15.5}, { 1,0,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[2] = th_att_lin[2] = CreateThruster ({0,0, 15.5}, { 1,0,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[3] = th_att_lin[1] = CreateThruster ({0,0,-15.5}, {-1,0,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_YAWLEFT); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_YAWRIGHT); CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_LEFT); CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_RIGHT); - AddExhaust (th_att_rot[0], eh, ew2, _V( 1.8 ,-0.3 , 18.0 ), _V( 1,0,0), tex_rcs);//F4R - AddExhaust (th_att_rot[0], eh, ew2, _V( 1.75, 0.1 , 18.05), _V( 1,0,0), tex_rcs);//F2R - AddExhaust (th_att_rot[2], eh, ew2, _V(-1.7 ,-0.3 , 18.0 ), _V(-1,0,0), tex_rcs);//F1L - AddExhaust (th_att_rot[2], eh, ew2, _V(-1.65,-0.1 , 18.05), _V(-1,0,0), tex_rcs);//F3L - - AddExhaust (th_att_rot[1], eh, ew2, _V(-4.0 , 2.35,-12.35), _V(-1,0,0), tex_rcs);//L4L - AddExhaust (th_att_rot[1], eh, ew2, _V(-4.0 , 2.35,-12.6 ), _V(-1,0,0), tex_rcs);//L2L - AddExhaust (th_att_rot[1], eh, ew2, _V(-4.0 , 2.35,-13.0 ), _V(-1,0,0), tex_rcs);//L3L - AddExhaust (th_att_rot[1], eh, ew2, _V(-4.0 , 2.35,-13.35), _V(-1,0,0), tex_rcs);//L1L - - AddExhaust (th_att_rot[3], eh, ew2, _V( 4.0 , 2.35,-12.35), _V( 1,0,0), tex_rcs);//R4R - AddExhaust (th_att_rot[3], eh, ew2, _V( 4.0 , 2.35,-12.6 ), _V( 1,0,0), tex_rcs);//R2R - AddExhaust (th_att_rot[3], eh, ew2, _V( 4.0 , 2.35,-13.0 ), _V( 1,0,0), tex_rcs);//R3R - AddExhaust (th_att_rot[3], eh, ew2, _V( 4.0, 2.35,-13.35), _V( 1,0,0), tex_rcs);//R1R - - th_att_rot[0] = CreateThruster (_V( 2.7,0,0), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[1] = CreateThruster (_V(-2.7,0,0), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[2] = CreateThruster (_V(-2.7,0,0), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_rot[3] = CreateThruster (_V( 2.7,0,0), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + AddExhaust (th_att_rot[0], eh, ew2, { 1.8 ,-0.3 , 18.0 }, { 1,0,0}, tex_rcs);//F4R + AddExhaust (th_att_rot[0], eh, ew2, { 1.75, 0.1 , 18.05}, { 1,0,0}, tex_rcs);//F2R + AddExhaust (th_att_rot[2], eh, ew2, {-1.7 ,-0.3 , 18.0 }, {-1,0,0}, tex_rcs);//F1L + AddExhaust (th_att_rot[2], eh, ew2, {-1.65,-0.1 , 18.05}, {-1,0,0}, tex_rcs);//F3L + + AddExhaust (th_att_rot[1], eh, ew2, {-4.0 , 2.35,-12.35}, {-1,0,0}, tex_rcs);//L4L + AddExhaust (th_att_rot[1], eh, ew2, {-4.0 , 2.35,-12.6 }, {-1,0,0}, tex_rcs);//L2L + AddExhaust (th_att_rot[1], eh, ew2, {-4.0 , 2.35,-13.0 }, {-1,0,0}, tex_rcs);//L3L + AddExhaust (th_att_rot[1], eh, ew2, {-4.0 , 2.35,-13.35}, {-1,0,0}, tex_rcs);//L1L + + AddExhaust (th_att_rot[3], eh, ew2, { 4.0 , 2.35,-12.35}, { 1,0,0}, tex_rcs);//R4R + AddExhaust (th_att_rot[3], eh, ew2, { 4.0 , 2.35,-12.6 }, { 1,0,0}, tex_rcs);//R2R + AddExhaust (th_att_rot[3], eh, ew2, { 4.0 , 2.35,-13.0 }, { 1,0,0}, tex_rcs);//R3R + AddExhaust (th_att_rot[3], eh, ew2, { 4.0, 2.35,-13.35}, { 1,0,0}, tex_rcs);//R1R + + th_att_rot[0] = CreateThruster ({ 2.7,0,0}, {0, 1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[1] = CreateThruster ({-2.7,0,0}, {0,-1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[2] = CreateThruster ({-2.7,0,0}, {0, 1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_rot[3] = CreateThruster ({ 2.7,0,0}, {0,-1,0}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_BANKLEFT); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_BANKRIGHT); - AddExhaust (th_att_rot[0], eh, ew1, _V( 1.60,-0.20, 18.78), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F2D - AddExhaust (th_att_rot[0], eh, ew1, _V( 1.68,-0.18, 18.40), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F4D - AddExhaust (th_att_rot[2], eh, ew1, _V(-1.55,-0.20, 18.78), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F1D - AddExhaust (th_att_rot[2], eh, ew1, _V(-1.63,-0.18, 18.40), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F3D + AddExhaust (th_att_rot[0], eh, ew1, { 1.60,-0.20, 18.78}, { 0.4339,-0.8830,-0.1793}, tex_rcs);//F2D + AddExhaust (th_att_rot[0], eh, ew1, { 1.68,-0.18, 18.40}, { 0.4339,-0.8830,-0.1793}, tex_rcs);//F4D + AddExhaust (th_att_rot[2], eh, ew1, {-1.55,-0.20, 18.78}, {-0.4339,-0.8830,-0.1793}, tex_rcs);//F1D + AddExhaust (th_att_rot[2], eh, ew1, {-1.63,-0.18, 18.40}, {-0.4339,-0.8830,-0.1793}, tex_rcs);//F3D - AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.30), _V(0, 1,0), tex_rcs);//L4U - AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.70), _V(0, 1,0), tex_rcs);//L2U - AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-13.10), _V(0, 1,0), tex_rcs);//L1U + AddExhaust (th_att_rot[1], eh, ew1, {-3.46, 3.20,-12.30}, {0, 1,0}, tex_rcs);//L4U + AddExhaust (th_att_rot[1], eh, ew1, {-3.46, 3.20,-12.70}, {0, 1,0}, tex_rcs);//L2U + AddExhaust (th_att_rot[1], eh, ew1, {-3.46, 3.20,-13.10}, {0, 1,0}, tex_rcs);//L1U - AddExhaust (th_att_rot[3], eh, ew1, _V( 3.43, 3.20,-12.30), _V(0, 1,0), tex_rcs);//R4U - AddExhaust (th_att_rot[3], eh, ew1, _V( 3.43, 3.20,-12.70), _V(0, 1,0), tex_rcs);//R2U - AddExhaust (th_att_rot[3], eh, ew1, _V( 3.43, 3.20,-13.10), _V(0, 1,0), tex_rcs);//R1U + AddExhaust (th_att_rot[3], eh, ew1, { 3.43, 3.20,-12.30}, {0, 1,0}, tex_rcs);//R4U + AddExhaust (th_att_rot[3], eh, ew1, { 3.43, 3.20,-12.70}, {0, 1,0}, tex_rcs);//R2U + AddExhaust (th_att_rot[3], eh, ew1, { 3.43, 3.20,-13.10}, {0, 1,0}, tex_rcs);//R1U - AddExhaust (th_att_rot[2], eh, ew1, _V(-3.1 , 1.55,-12.45), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L4D - AddExhaust (th_att_rot[2], eh, ew1, _V(-3.1 , 1.6 ,-12.8 ), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L2D - AddExhaust (th_att_rot[2], eh, ew1, _V(-3.1 , 1.65,-13.15), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L3D + AddExhaust (th_att_rot[2], eh, ew1, {-3.1 , 1.55,-12.45}, {-0.2844,-0.9481,-0.1422}, tex_rcs);//L4D + AddExhaust (th_att_rot[2], eh, ew1, {-3.1 , 1.6 ,-12.8 }, {-0.2844,-0.9481,-0.1422}, tex_rcs);//L2D + AddExhaust (th_att_rot[2], eh, ew1, {-3.1 , 1.65,-13.15}, {-0.2844,-0.9481,-0.1422}, tex_rcs);//L3D - AddExhaust (th_att_rot[0], eh, ew1, _V( 3.15, 1.55,-12.45), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R4D - AddExhaust (th_att_rot[0], eh, ew1, _V( 3.15, 1.6 ,-12.8 ), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R2D - AddExhaust (th_att_rot[0], eh, ew1, _V( 3.15, 1.65,-13.15), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R3D + AddExhaust (th_att_rot[0], eh, ew1, { 3.15, 1.55,-12.45}, { 0.2844,-0.9481,-0.1422}, tex_rcs);//R4D + AddExhaust (th_att_rot[0], eh, ew1, { 3.15, 1.6 ,-12.8 }, { 0.2844,-0.9481,-0.1422}, tex_rcs);//R2D + AddExhaust (th_att_rot[0], eh, ew1, { 3.15, 1.65,-13.15}, { 0.2844,-0.9481,-0.1422}, tex_rcs);//R3D - th_att_lin[0] = CreateThruster (_V(0,0,-16), _V(0,0, 1), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); - th_att_lin[1] = CreateThruster (_V(0,0, 16), _V(0,0,-1), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_lin[0] = CreateThruster ({0,0,-16}, {0,0, 1}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); + th_att_lin[1] = CreateThruster ({0,0, 16}, {0,0,-1}, ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1); CreateThrusterGroup (th_att_lin, 1, THGROUP_ATT_FORWARD); CreateThrusterGroup (th_att_lin+1, 1, THGROUP_ATT_BACK); - AddExhaust (th_att_lin[0], eh, ew1, _V(-3.59, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//L1A - AddExhaust (th_att_lin[0], eh, ew1, _V(-3.27, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//L3A - AddExhaust (th_att_lin[0], eh, ew1, _V( 3.64, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//R1A - AddExhaust (th_att_lin[0], eh, ew1, _V( 3.27, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//R3A + AddExhaust (th_att_lin[0], eh, ew1, {-3.59, 2.8 ,-13.6 }, {0,0,-1}, tex_rcs);//L1A + AddExhaust (th_att_lin[0], eh, ew1, {-3.27, 2.8 ,-13.6 }, {0,0,-1}, tex_rcs);//L3A + AddExhaust (th_att_lin[0], eh, ew1, { 3.64, 2.8 ,-13.6 }, {0,0,-1}, tex_rcs);//R1A + AddExhaust (th_att_lin[0], eh, ew1, { 3.27, 2.8 ,-13.6 }, {0,0,-1}, tex_rcs);//R3A - AddExhaust (th_att_lin[1], eh, ew1, _V( 0.0 , 0.75, 19.2 ), _V(0, 0.0499, 0.9988), tex_rcs);//F3F - AddExhaust (th_att_lin[1], eh, ew1, _V(-0.4 , 0.7 , 19.2 ), _V(0, 0.0499, 0.9988), tex_rcs);//F1F - AddExhaust (th_att_lin[1], eh, ew1, _V( 0.4 , 0.7 , 19.2 ), _V(0, 0.0499, 0.9988), tex_rcs);//F2F + AddExhaust (th_att_lin[1], eh, ew1, { 0.0 , 0.75, 19.2 }, {0, 0.0499, 0.9988}, tex_rcs);//F3F + AddExhaust (th_att_lin[1], eh, ew1, {-0.4 , 0.7 , 19.2 }, {0, 0.0499, 0.9988}, tex_rcs);//F1F + AddExhaust (th_att_lin[1], eh, ew1, { 0.4 , 0.7 , 19.2 }, {0, 0.0499, 0.9988}, tex_rcs);//F2F } // -------------------------------------------------------------- @@ -340,18 +340,18 @@ void Atlantis::CreateRCS() // -------------------------------------------------------------- void Atlantis::CreateAirfoils () { - CreateAirfoil (LIFT_VERTICAL, _V(0,0,-0.5), VLiftCoeff, 20, 270, 2.266); - CreateAirfoil (LIFT_HORIZONTAL, _V(0,0,-4), HLiftCoeff, 20, 50, 1.5); + CreateAirfoil (LIFT_VERTICAL, {0,0,-0.5}, VLiftCoeff, 20, 270, 2.266); + CreateAirfoil (LIFT_HORIZONTAL, {0,0,-4}, HLiftCoeff, 20, 50, 1.5); - CreateControlSurface (AIRCTRL_ELEVATOR, 5.0, 1.5, _V( 0, 0, -15), AIRCTRL_AXIS_XPOS, anim_elev); - CreateControlSurface (AIRCTRL_RUDDER, 2.0, 1.5, _V( 0, 3, -16), AIRCTRL_AXIS_YPOS, anim_rudder); - CreateControlSurface (AIRCTRL_AILERON, 3.0, 1.5, _V( 7,-0.5,-15), AIRCTRL_AXIS_XPOS, anim_raileron); - CreateControlSurface (AIRCTRL_AILERON, 3.0, 1.5, _V(-7,-0.5,-15), AIRCTRL_AXIS_XNEG, anim_laileron); + CreateControlSurface (AIRCTRL_ELEVATOR, 5.0, 1.5, { 0, 0, -15}, AIRCTRL_AXIS_XPOS, anim_elev); + CreateControlSurface (AIRCTRL_RUDDER, 2.0, 1.5, { 0, 3, -16}, AIRCTRL_AXIS_YPOS, anim_rudder); + CreateControlSurface (AIRCTRL_AILERON, 3.0, 1.5, { 7,-0.5,-15}, AIRCTRL_AXIS_XPOS, anim_raileron); + CreateControlSurface (AIRCTRL_AILERON, 3.0, 1.5, {-7,-0.5,-15}, AIRCTRL_AXIS_XNEG, anim_laileron); - CreateVariableDragElement (&spdb_proc, 5, _V(0, 7.5, -14)); // speedbrake drag - CreateVariableDragElement (&gear_proc, 2, _V(0,-3,0)); // landing gear drag - CreateVariableDragElement (&rdoor_drag, 7, _V(2.9,0,10)); // right cargo door drag - CreateVariableDragElement (&ldoor_drag, 7, _V(-2.9,0,10)); // right cargo door drag + CreateVariableDragElement (&spdb_proc, 5, {0, 7.5, -14}); // speedbrake drag + CreateVariableDragElement (&gear_proc, 2, {0,-3,0}); // landing gear drag + CreateVariableDragElement (&rdoor_drag, 7, {2.9,0,10}); // right cargo door drag + CreateVariableDragElement (&ldoor_drag, 7, {-2.9,0,10}); // right cargo door drag } // -------------------------------------------------------------- @@ -500,10 +500,10 @@ void Atlantis::DefineAnimations (void) static UINT RCargoDoorGrp[4] = {GRP_cargodooroutR,GRP_cargodoorinR,GRP_radiatorFR,GRP_radiatorBR}; static MGROUP_ROTATE RCargoDoor (midx, RCargoDoorGrp, 4, - _V(2.88, 1.3, 0), _V(0,0,1), (float)(-175.5*RAD)); + {2.88, 1.3, 0}, {0,0,1}, (float)(-175.5*RAD)); static UINT LCargoDoorGrp[4] = {GRP_cargodooroutL,GRP_cargodoorinL,GRP_radiatorFL,GRP_radiatorBL}; static MGROUP_ROTATE LCargoDoor (midx, LCargoDoorGrp, 4, - _V(-2.88, 1.3, 0), _V(0,0,1), (float)(175.5*RAD)); + {-2.88, 1.3, 0}, {0,0,1}, (float)(175.5*RAD)); anim_door = CreateAnimation (0); AddAnimationComponent (anim_door, 0.0, 0.4632, &RCargoDoor); @@ -511,10 +511,10 @@ void Atlantis::DefineAnimations (void) static UINT RRadiatorGrp[1] = {GRP_radiatorFR}; static MGROUP_ROTATE RRadiator (midx, RRadiatorGrp, 1, - _V(2.88, 1.3, 0), _V(0,0,1), (float)(35.5*RAD)); + {2.88, 1.3, 0}, {0,0,1}, (float)(35.5*RAD)); static UINT LRadiatorGrp[1] = {GRP_radiatorFL}; static MGROUP_ROTATE LRadiator (midx, LRadiatorGrp, 1, - _V(-2.88, 1.3, 0), _V(0,0,1), (float)(-35.5*RAD)); + {-2.88, 1.3, 0}, {0,0,1}, (float)(-35.5*RAD)); anim_rad = CreateAnimation (0); AddAnimationComponent (anim_rad, 0, 1, &RRadiator); @@ -524,22 +524,22 @@ void Atlantis::DefineAnimations (void) static UINT LNosewheelDoorGrp[1] = {GRP_nosedoorL}; static MGROUP_ROTATE LNosewheelDoor (midx, LNosewheelDoorGrp, 1, - _V(-0.78, -2.15, 17), _V(0, 0.195, 0.981), (float)(-60.0*RAD)); + {-0.78, -2.15, 17}, {0, 0.195, 0.981}, (float)(-60.0*RAD)); static UINT RNosewheelDoorGrp[1] = {GRP_nosedoorR}; static MGROUP_ROTATE RNosewheelDoor (midx, RNosewheelDoorGrp, 1, - _V(0.78, -2.15, 17), _V(0, 0.195, 0.981), (float)(60.0*RAD)); + {0.78, -2.15, 17}, {0, 0.195, 0.981}, (float)(60.0*RAD)); static UINT NosewheelGrp[2] = {GRP_nosewheel,GRP_nosegear}; static MGROUP_ROTATE Nosewheel (midx, NosewheelGrp, 2, - _V(0.0, -1.95, 17.45), _V(1, 0, 0), (float)(109.0*RAD)); + {0.0, -1.95, 17.45}, {1, 0, 0}, (float)(109.0*RAD)); static UINT RGearDoorGrp[1] = {GRP_geardoorR}; static MGROUP_ROTATE RGearDoor (midx, RGearDoorGrp, 1, - _V(4.35, -2.64, -1.69), _V(0, 0.02, 0.9), (float)(96.2*RAD)); + {4.35, -2.64, -1.69}, {0, 0.02, 0.9}, (float)(96.2*RAD)); static UINT LGearDoorGrp[1] = {GRP_geardoorL}; static MGROUP_ROTATE LGearDoor (midx, LGearDoorGrp, 1, - _V(-4.35, -2.64, -1.69), _V(0, 0.02, 0.9), (float)(-96.2*RAD)); + {-4.35, -2.64, -1.69}, {0, 0.02, 0.9}, (float)(-96.2*RAD)); static UINT MainGearGrp[4] = {GRP_wheelR,GRP_gearR,GRP_wheelL,GRP_gearL}; static MGROUP_ROTATE MainGear (midx, MainGearGrp, 4, - _V(0, -2.66, -3.68), _V(1, 0, 0), (float)(94.5*RAD)); + {0, -2.66, -3.68}, {1, 0, 0}, (float)(94.5*RAD)); anim_gear = CreateAnimation (0); AddAnimationComponent (anim_gear, 0, 0.5, &LNosewheelDoor); @@ -553,13 +553,13 @@ void Atlantis::DefineAnimations (void) static UINT KuBand1Grp[3] = {GRP_startrackers,GRP_KUband1,GRP_KUband2}; static MGROUP_ROTATE KuBand1 (midx, KuBand1Grp, 3, - _V(2.85, 0.85, 0), _V(0,0,1), (float)(-18*RAD)); + {2.85, 0.85, 0}, {0,0,1}, (float)(-18*RAD)); static UINT KuBand2Grp[1] = {GRP_KUband2}; static MGROUP_ROTATE KuBand2 (midx, KuBand2Grp, 1, - _V(2.78, 1.7, 0), _V(0,0,1), (float)(-90*RAD)); + {2.78, 1.7, 0}, {0,0,1}, (float)(-90*RAD)); static UINT KuBand3Grp[2] = {GRP_KUband1,GRP_KUband2}; static MGROUP_ROTATE KuBand3 (midx, KuBand3Grp, 2, - _V(2.75, 2.05, 11.47), _V(0,1,0), (float)(-113*RAD)); + {2.75, 2.05, 11.47}, {0,1,0}, (float)(-113*RAD)); anim_kubd = CreateAnimation (0); AddAnimationComponent (anim_kubd, 0, 0.333, &KuBand1); @@ -570,7 +570,7 @@ void Atlantis::DefineAnimations (void) static UINT ElevGrp[4] = {GRP_flapR,GRP_flapL,GRP_aileronL,GRP_aileronR}; static MGROUP_ROTATE Elevator (midx, ElevGrp, 4, - _V(0,-2.173,-8.84), _V(1,0,0), (float)(30.0*RAD)); + {0,-2.173,-8.84}, {1,0,0}, (float)(30.0*RAD)); anim_elev = CreateAnimation (0.5); AddAnimationComponent (anim_elev, 0, 1, &Elevator); @@ -578,10 +578,10 @@ void Atlantis::DefineAnimations (void) static UINT LAileronGrp[2] = {GRP_flapL,GRP_aileronL}; static MGROUP_ROTATE LAileron (midx, LAileronGrp, 2, - _V(0,-2.173,-8.84), _V(-1,0,0), (float)(10.0*RAD)); + {0,-2.173,-8.84}, {-1,0,0}, (float)(10.0*RAD)); static UINT RAileronGrp[2] = {GRP_flapR,GRP_aileronR}; static MGROUP_ROTATE RAileron (midx, RAileronGrp, 2, - _V(0,-2.173,-8.84), _V(1,0,0), (float)(10.0*RAD)); + {0,-2.173,-8.84}, {1,0,0}, (float)(10.0*RAD)); anim_laileron = CreateAnimation (0.5); AddAnimationComponent (anim_laileron, 0, 1, &LAileron); anim_raileron = CreateAnimation (0.5); @@ -591,7 +591,7 @@ void Atlantis::DefineAnimations (void) static UINT RudderGrp[2] = {GRP_rudderR,GRP_rudderL}; static MGROUP_ROTATE Rudder (midx, RudderGrp, 2, - _V(0,5.77,-12.17), _V(-0.037,0.833,-0.552), (float)(-54.2*RAD)); + {0,5.77,-12.17}, {-0.037,0.833,-0.552}, (float)(-54.2*RAD)); anim_rudder = CreateAnimation (0.5); AddAnimationComponent (anim_rudder, 0, 1, &Rudder); @@ -599,10 +599,10 @@ void Atlantis::DefineAnimations (void) static UINT SB1Grp[1] = {GRP_rudderR}; static MGROUP_ROTATE SB1 (midx, SB1Grp, 1, - _V(0.32,5.77,-12.17), _V(-0.037,0.833,-0.552), (float)(-49.3*RAD)); + {0.32,5.77,-12.17}, {-0.037,0.833,-0.552}, (float)(-49.3*RAD)); static UINT SB2Grp[1] = {GRP_rudderL}; static MGROUP_ROTATE SB2 (midx, SB2Grp, 1, - _V(-0.32,5.77,-12.17), _V(0.037,0.833,-0.552), (float)(49.3*RAD)); + {-0.32,5.77,-12.17}, {0.037,0.833,-0.552}, (float)(49.3*RAD)); anim_spdb = CreateAnimation (0); AddAnimationComponent (anim_spdb, 0, 1, &SB1); @@ -616,36 +616,36 @@ void Atlantis::DefineAnimations (void) static UINT RMSShoulderYawGrp[1] = {GRP_Shoulder}; rms_anim[0] = new MGROUP_ROTATE (midx, RMSShoulderYawGrp, 1, - _V(-2.26, 1.70, 9.65), _V(0, 1, 0), (float)(-360*RAD)); // -180 .. +180 + {-2.26, 1.70, 9.65}, {0, 1, 0}, (float)(-360*RAD)); // -180 .. +180 anim_arm_sy = CreateAnimation (0.5); parent = AddAnimationComponent (anim_arm_sy, 0, 1, rms_anim[0]); static UINT RMSShoulderPitchGrp[1] = {GRP_Humerus}; rms_anim[1] = new MGROUP_ROTATE (midx, RMSShoulderPitchGrp, 1, - _V(-2.26, 1.70, 9.65), _V(1, 0, 0), (float)(147*RAD)); // -2 .. +145 + {-2.26, 1.70, 9.65}, {1, 0, 0}, (float)(147*RAD)); // -2 .. +145 anim_arm_sp = CreateAnimation (0.0136); parent = AddAnimationComponent (anim_arm_sp, 0, 1, rms_anim[1], parent); static UINT RMSElbowPitchGrp[3] = {GRP_radii,GRP_RMScamera,GRP_RMScamera_pivot}; rms_anim[2] = new MGROUP_ROTATE (midx, RMSElbowPitchGrp, 3, - _V(-2.26,1.55,3.10), _V(1,0,0), (float)(-162*RAD)); // -160 .. +2 + {-2.26,1.55,3.10}, {1,0,0}, (float)(-162*RAD)); // -160 .. +2 anim_arm_ep = CreateAnimation (0.0123); parent = AddAnimationComponent (anim_arm_ep, 0, 1, rms_anim[2], parent); static UINT RMSWristPitchGrp[1] = {GRP_wrist}; rms_anim[3] = new MGROUP_ROTATE (midx, RMSWristPitchGrp, 1, - _V(-2.26,1.7,-3.55), _V(1,0,0), (float)(240*RAD)); // -120 .. +120 + {-2.26,1.7,-3.55}, {1,0,0}, (float)(240*RAD)); // -120 .. +120 anim_arm_wp = CreateAnimation (0.5); parent = AddAnimationComponent (anim_arm_wp, 0, 1, rms_anim[3], parent); static UINT RMSWristYawGrp[1] = {GRP_endeffecter}; rms_anim[4] = new MGROUP_ROTATE (midx, RMSWristYawGrp, 1, - _V(-2.26,1.7,-4.9), _V(0,1,0), (float)(-240*RAD)); // -120 .. +120 + {-2.26,1.7,-4.9}, {0,1,0}, (float)(-240*RAD)); // -120 .. +120 anim_arm_wy = CreateAnimation (0.5); parent = AddAnimationComponent (anim_arm_wy, 0, 1, rms_anim[4], parent); rms_anim[5] = new MGROUP_ROTATE (LOCALVERTEXLIST, MAKEGROUPARRAY(arm_tip), 3, - _V(-2.26,1.7,-6.5), _V(0,0,1), (float)(894*RAD)); // -447 .. +447 + {-2.26,1.7,-6.5}, {0,0,1}, (float)(894*RAD)); // -447 .. +447 anim_arm_wr = CreateAnimation (0.5); hAC_arm = AddAnimationComponent (anim_arm_wr, 0, 1, rms_anim[5], parent); @@ -655,15 +655,15 @@ void Atlantis::DefineAnimations (void) anim_ssme = CreateAnimation (init_gimbal/max_gimbal); static UINT SSMEL_Grp = GRP_SSMEL; - ssme_anim[0] = new MGROUP_ROTATE (midx, &SSMEL_Grp, 1, _V(-1.55,-0.37,-12.5), _V(-1,0,0), max_gimbal); + ssme_anim[0] = new MGROUP_ROTATE (midx, &SSMEL_Grp, 1, {-1.55,-0.37,-12.5}, {-1,0,0}, max_gimbal); AddAnimationComponent (anim_ssme, 0, 1, ssme_anim[0]); static UINT SSMER_Grp = GRP_SSMER; - ssme_anim[1] = new MGROUP_ROTATE (midx, &SSMER_Grp, 1, _V( 1.55,-0.37,-12.5), _V(-1,0,0), max_gimbal); + ssme_anim[1] = new MGROUP_ROTATE (midx, &SSMER_Grp, 1, { 1.55,-0.37,-12.5}, {-1,0,0}, max_gimbal); AddAnimationComponent (anim_ssme, 0, 1, ssme_anim[1]); static UINT SSMET_Grp = GRP_SSMET; - ssme_anim[2] = new MGROUP_ROTATE (midx, &SSMET_Grp, 1, _V(0.0, 2.7, -12.5), _V(-1,0,0), max_gimbal); + ssme_anim[2] = new MGROUP_ROTATE (midx, &SSMET_Grp, 1, {0.0, 2.7, -12.5}, {-1,0,0}, max_gimbal); AddAnimationComponent (anim_ssme, 0, 1, ssme_anim[2]); // ====================================================== @@ -1017,7 +1017,7 @@ void Atlantis::AutoGimbal (const VECTOR3 &tgt_rate) // Set SRB gimbals if (status < 2 && pET) { pET->SetSRBGimbal (gimbal_pos); - SetSSMEGimbal (_V(gimbal_pos.x,0,0)); // If SRBs are available, we gimbal the SSMEs only in pitch + SetSSMEGimbal ({gimbal_pos.x,0,0}); // If SRBs are available, we gimbal the SSMEs only in pitch } else { SetSSMEGimbal (gimbal_pos); } @@ -1080,7 +1080,7 @@ void Atlantis::LaunchClamps () { // TODO #ifdef UNDEF - VECTOR3 F, T, r = _V(0,0,0), Fc = _V(0,0,0), Tc = _V(0,0,0); + VECTOR3 F, T, r = {0,0,0}, Fc = {0,0,0}, Tc = {0,0,0}; GetThrusterMoment (th_srb[0], F, T); Fc.z = -2*F.z; Tc.x = 2*T.x; @@ -1095,7 +1095,7 @@ void Atlantis::LaunchClamps () r.z = (Fc.y ? Tc.x/Fc.y : 0); AddForce (Fc, r); - Tc = _V(0,0,0); + Tc = {0,0,0}; GetThrusterMoment(th_srb[0], F, T); Tc += T; GetThrusterMoment(th_srb[1], F, T); @@ -1110,35 +1110,35 @@ void Atlantis::LaunchClamps () void Atlantis::SetGearParameters (double state) { static TOUCHDOWNVTX tdvtx[14] = { - {_V( 0, -3.3,18.75), 1e8, 1e6, 1.6, 0.1}, - {_V(-3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2}, - {_V( 3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2}, - {_V(-11.9, -2.1, -10), 1e8, 1e6, 3}, - {_V( 11.9, -2.1, -10), 1e8, 1e6, 3}, - {_V(-11.3, -2.1, -6), 1e8, 1e6, 3}, - {_V( 11.3, -2.1, -6), 1e8, 1e6, 3}, - {_V(-2.95, -2.0,-14.35),1e8, 1e6, 3}, - {_V( 2.95, -2.0,-14.35),1e8, 1e6, 3}, - {_V(-1.9, -1.0,-14.8), 1e8, 1e6, 3}, - {_V( 1.9, -1.0,-14.8), 1e8, 1e6, 3}, - {_V( 0, 11.2,-16.4), 1e8, 1e6, 3}, - {_V( 0, 11.3,-14.0), 1e8, 1e6, 3}, - {_V( 0, -0.9, 20.6), 1e8, 1e6, 3} + {{ 0, -3.3,18.75}, 1e8, 1e6, 1.6, 0.1}, + {{-3.96, -5.5, -3.2}, 1e8, 1e6, 3, 0.2}, + {{ 3.96, -5.5, -3.2}, 1e8, 1e6, 3, 0.2}, + {{-11.9, -2.1, -10}, 1e8, 1e6, 3}, + {{ 11.9, -2.1, -10}, 1e8, 1e6, 3}, + {{-11.3, -2.1, -6}, 1e8, 1e6, 3}, + {{ 11.3, -2.1, -6}, 1e8, 1e6, 3}, + {{-2.95, -2.0,-14.35},1e8, 1e6, 3}, + {{ 2.95, -2.0,-14.35},1e8, 1e6, 3}, + {{-1.9, -1.0,-14.8}, 1e8, 1e6, 3}, + {{ 1.9, -1.0,-14.8}, 1e8, 1e6, 3}, + {{ 0, 11.2,-16.4}, 1e8, 1e6, 3}, + {{ 0, 11.3,-14.0}, 1e8, 1e6, 3}, + {{ 0, -0.9, 20.6}, 1e8, 1e6, 3} }; if (state == 1.0) { // gear fully deployed static TOUCHDOWNVTX geardn_vtx[3] = { - {_V( 0, -3.95,17.5), 1e8, 1e6, 1.6, 0.1}, - {_V(-3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2}, - {_V( 3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2}, + {{ 0, -3.95,17.5}, 1e8, 1e6, 1.6, 0.1}, + {{-3.96, -5.5, -3.2}, 1e8, 1e6, 3, 0.2}, + {{ 3.96, -5.5, -3.2}, 1e8, 1e6, 3, 0.2}, }; memcpy (tdvtx, geardn_vtx, 3*sizeof(TOUCHDOWNVTX)); SetTouchdownPoints (tdvtx, 14); SetSurfaceFrictionCoeff (0.05, 0.4); } else { static TOUCHDOWNVTX gearup_vtx[3] = { - {_V( 0, -2.2,16.75), 1e8, 1e6, 3}, - {_V(-3.96, -2.7, -3.2), 1e8, 1e6, 3}, - {_V( 3.96, -2.7, -3.2), 1e8, 1e6, 3}, + {{ 0, -2.2,16.75}, 1e8, 1e6, 3}, + {{-3.96, -2.7, -3.2}, 1e8, 1e6, 3}, + {{ 3.96, -2.7, -3.2}, 1e8, 1e6, 3}, }; memcpy (tdvtx, gearup_vtx, 3*sizeof(TOUCHDOWNVTX)); SetTouchdownPoints (tdvtx, 14); @@ -1310,10 +1310,10 @@ void Atlantis::clbkSetClassCaps (FILEHANDLE cfg) SetSize (19.6); SetEmptyMass (ORBITER_EMPTY_MASS); - SetPMI (_V(78.2,82.1,10.7)); + SetPMI ({78.2,82.1,10.7}); SetGravityGradientDamping (20.0); SetCrossSections (ORBITER_CS); - SetRotDrag (_V(0.43,0.43,0.29)); // angular drag + SetRotDrag ({0.43,0.43,0.29}); // angular drag SetTrimScale (0.05); launchelev = 0.0; @@ -1389,7 +1389,7 @@ void Atlantis::clbkLoadStateEx (FILEHANDLE scn, void *vs) vs2->arot.z = atan2(clng*slat*cdir+slng*sdir, clng*slat*sdir-slng*cdir); } } else { - double rad = length(vs2->rpos); + double rad = len(vs2->rpos); double alt = rad - oapiGetSize(vs2->rbody); launchelev = max (0.0, alt - 18.962); } @@ -1399,7 +1399,7 @@ void Atlantis::clbkLoadStateEx (FILEHANDLE scn, void *vs) ofs_sts_sat.x=sts_sat_x; ofs_sts_sat.y=sts_sat_y; ofs_sts_sat.z=sts_sat_z; - SetAttachmentParams (sat_attach, ofs_sts_sat, _V(0,1,0), _V(0,0,1)); + SetAttachmentParams (sat_attach, ofs_sts_sat, {0,1,0}, {0,0,1}); } // optional meshes @@ -1407,7 +1407,7 @@ void Atlantis::clbkLoadStateEx (FILEHANDLE scn, void *vs) mesh_cargo = AddMesh (cargo_static_mesh_name, &cargo_static_ofs); } if (do_plat && !mesh_platform) { - VECTOR3 plat_ofs = _V(-2.59805, 1.69209, -5.15524); + VECTOR3 plat_ofs = {-2.59805, 1.69209, -5.15524}; mesh_platform = AddMesh("shuttle_eva_plat", &plat_ofs); } t0 = ascap->GetMT0(); @@ -1552,7 +1552,7 @@ void Atlantis::clbkPreStep (double simt, double simdt, double mjd) engine_light_level = GetThrusterGroupLevel (THGROUP_MAIN); - VECTOR3 tgt_rate = _V(0,0,0); // target rotation rates - used for setting engine gimbals + VECTOR3 tgt_rate = {0,0,0}; // target rotation rates - used for setting engine gimbals if (status >= 1 && status <= 3) { // ascent autopilot @@ -1814,8 +1814,8 @@ void Atlantis::clbkMFDMode (int mfd, int mode) // -------------------------------------------------------------- bool Atlantis::clbkLoadGenericCockpit () { - SetCameraOffset (_V(-0.67,2.55,14.4)); - SetCameraDefaultDirection (_V(0,0,1)); + SetCameraOffset ({-0.67,2.55,14.4}); + SetCameraDefaultDirection ({0,0,1}); return true; } @@ -1826,21 +1826,21 @@ bool Atlantis::clbkLoadGenericCockpit () void Atlantis::RegisterVC_CdrMFD () { // activate MFD function buttons - oapiVCSetAreaClickmode_Quadrilateral (AID_CDR1_BUTTONS, _V(-0.9239,2.0490,15.0595), _V(-0.7448,2.0490,15.0595), _V(-0.9239,2.0280,15.0595), _V(-0.7448,2.0280,15.0595)); - oapiVCSetAreaClickmode_Quadrilateral (AID_CDR2_BUTTONS, _V(-0.6546,2.0490,15.0595), _V(-0.4736,2.0490,15.0595), _V(-0.6546,2.0280,15.0595), _V(-0.4736,2.0280,15.0595)); + oapiVCSetAreaClickmode_Quadrilateral (AID_CDR1_BUTTONS, {-0.9239,2.0490,15.0595}, {-0.7448,2.0490,15.0595}, {-0.9239,2.0280,15.0595}, {-0.7448,2.0280,15.0595}); + oapiVCSetAreaClickmode_Quadrilateral (AID_CDR2_BUTTONS, {-0.6546,2.0490,15.0595}, {-0.4736,2.0490,15.0595}, {-0.6546,2.0280,15.0595}, {-0.4736,2.0280,15.0595}); // D. Beachy: register+activate MFD power buttons const double powerButtonRadius = 0.0075; // radius of power button on each MFD oapiVCRegisterArea (AID_CDR1_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_CDR2_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Spherical(AID_CDR1_PWR, _V(-0.950, 2.060, 15.060), powerButtonRadius); - oapiVCSetAreaClickmode_Spherical(AID_CDR2_PWR, _V(-0.680, 2.060, 15.060), powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_CDR1_PWR, {-0.950, 2.060, 15.060}, powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_CDR2_PWR, {-0.680, 2.060, 15.060}, powerButtonRadius); // register+activate MFD brightness buttons oapiVCRegisterArea (AID_CDR1_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_CDR2_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Quadrilateral (AID_CDR1_BRT, _V(-0.729,2.0675,15.060), _V(-0.714,2.0675,15.060), _V(-0.729,2.0525,15.060), _V(-0.714,2.0525,15.060)); - oapiVCSetAreaClickmode_Quadrilateral (AID_CDR2_BRT, _V(-0.459,2.0675,15.060), _V(-0.444,2.0675,15.060), _V(-0.459,2.0525,15.060), _V(-0.444,2.0525,15.060)); + oapiVCSetAreaClickmode_Quadrilateral (AID_CDR1_BRT, {-0.729,2.0675,15.060}, {-0.714,2.0675,15.060}, {-0.729,2.0525,15.060}, {-0.714,2.0525,15.060}); + oapiVCSetAreaClickmode_Quadrilateral (AID_CDR2_BRT, {-0.459,2.0675,15.060}, {-0.444,2.0675,15.060}, {-0.459,2.0525,15.060}, {-0.444,2.0525,15.060}); } // -------------------------------------------------------------- @@ -1850,21 +1850,21 @@ void Atlantis::RegisterVC_CdrMFD () void Atlantis::RegisterVC_PltMFD () { // activate MFD function buttons - oapiVCSetAreaClickmode_Quadrilateral (AID_PLT1_BUTTONS, _V(0.4759,2.0490,15.0595), _V(0.6568,2.0490,15.0595), _V(0.4759,2.0280,15.0595), _V(0.6568,2.0280,15.0595)); - oapiVCSetAreaClickmode_Quadrilateral (AID_PLT2_BUTTONS, _V(0.7461,2.0490,15.0595), _V(0.9271,2.0490,15.0595), _V(0.7461,2.0280,15.0595), _V(0.9271,2.0280,15.0595)); + oapiVCSetAreaClickmode_Quadrilateral (AID_PLT1_BUTTONS, {0.4759,2.0490,15.0595}, {0.6568,2.0490,15.0595}, {0.4759,2.0280,15.0595}, {0.6568,2.0280,15.0595}); + oapiVCSetAreaClickmode_Quadrilateral (AID_PLT2_BUTTONS, {0.7461,2.0490,15.0595}, {0.9271,2.0490,15.0595}, {0.7461,2.0280,15.0595}, {0.9271,2.0280,15.0595}); // D. Beachy: register+activate MFD power buttons const double powerButtonRadius = 0.0075; // radius of power button on each MFD oapiVCRegisterArea (AID_PLT1_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_PLT2_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Spherical(AID_PLT1_PWR, _V( 0.450, 2.060, 15.060), powerButtonRadius); - oapiVCSetAreaClickmode_Spherical(AID_PLT2_PWR, _V( 0.720, 2.060, 15.060), powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_PLT1_PWR, { 0.450, 2.060, 15.060}, powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_PLT2_PWR, { 0.720, 2.060, 15.060}, powerButtonRadius); // register+activate MFD brightness buttons oapiVCRegisterArea (AID_PLT1_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_PLT2_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Quadrilateral (AID_PLT1_BRT, _V(0.671,2.0675,15.060), _V(0.686,2.0675,15.060), _V(0.671,2.0525,15.060), _V(0.686,2.0525,15.060)); - oapiVCSetAreaClickmode_Quadrilateral (AID_PLT2_BRT, _V(0.941,2.0675,15.060), _V(0.956,2.0675,15.060), _V(0.941,2.0525,15.060), _V(0.956,2.0525,15.060)); + oapiVCSetAreaClickmode_Quadrilateral (AID_PLT1_BRT, {0.671,2.0675,15.060}, {0.686,2.0675,15.060}, {0.671,2.0525,15.060}, {0.686,2.0525,15.060}); + oapiVCSetAreaClickmode_Quadrilateral (AID_PLT2_BRT, {0.941,2.0675,15.060}, {0.956,2.0675,15.060}, {0.941,2.0525,15.060}, {0.956,2.0525,15.060}); } // -------------------------------------------------------------- @@ -1874,11 +1874,11 @@ void Atlantis::RegisterVC_PltMFD () void Atlantis::RegisterVC_CntMFD () { // activate MFD function buttons - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD1_BUTTONS, _V(-0.3579,2.1451,15.0863), _V(-0.1770,2.1451,15.0863), _V(-0.3579,2.1241,15.0863), _V(-0.1770,2.1241,15.0863)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD2_BUTTONS, _V(-0.3579,1.9143,15.0217), _V(-0.1770,1.9143,15.0217), _V(-0.3579,1.8933,15.0217), _V(-0.1770,1.8933,15.0217)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD3_BUTTONS, _V(-0.0888,2.0288,15.0538), _V(0.0922,2.0288,15.0538), _V(-0.0888,2.0078,15.0538), _V(0.0922,2.0078,15.0538)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD4_BUTTONS, _V(0.1795,2.1451,15.0863), _V(0.3604,2.1451,15.0863), _V(0.1795,2.1241,15.0863), _V(0.3604,2.1241,15.0863)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD5_BUTTONS, _V(0.1795,1.9143,15.0217), _V(0.3604,1.9143,15.0217), _V(0.1795,1.8933,15.0217), _V(0.3604,1.8933,15.0217)); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD1_BUTTONS, {-0.3579,2.1451,15.0863}, {-0.1770,2.1451,15.0863}, {-0.3579,2.1241,15.0863}, {-0.1770,2.1241,15.0863}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD2_BUTTONS, {-0.3579,1.9143,15.0217}, {-0.1770,1.9143,15.0217}, {-0.3579,1.8933,15.0217}, {-0.1770,1.8933,15.0217}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD3_BUTTONS, {-0.0888,2.0288,15.0538}, {0.0922,2.0288,15.0538}, {-0.0888,2.0078,15.0538}, {0.0922,2.0078,15.0538}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD4_BUTTONS, {0.1795,2.1451,15.0863}, {0.3604,2.1451,15.0863}, {0.1795,2.1241,15.0863}, {0.3604,2.1241,15.0863}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD5_BUTTONS, {0.1795,1.9143,15.0217}, {0.3604,1.9143,15.0217}, {0.1795,1.8933,15.0217}, {0.3604,1.8933,15.0217}); // D. Beachy: register+activate MFD power buttons const double powerButtonRadius = 0.0075; // radius of power button on each MFD @@ -1887,11 +1887,11 @@ void Atlantis::RegisterVC_CntMFD () oapiVCRegisterArea (AID_MFD3_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_MFD4_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_MFD5_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Spherical(AID_MFD1_PWR, _V(-0.383, 2.153, 15.090), powerButtonRadius); - oapiVCSetAreaClickmode_Spherical(AID_MFD2_PWR, _V(-0.383, 1.922, 15.023), powerButtonRadius); - oapiVCSetAreaClickmode_Spherical(AID_MFD3_PWR, _V(-0.114, 2.037, 15.058), powerButtonRadius); - oapiVCSetAreaClickmode_Spherical(AID_MFD4_PWR, _V( 0.155, 2.153, 15.090), powerButtonRadius); - oapiVCSetAreaClickmode_Spherical(AID_MFD5_PWR, _V( 0.155, 1.922, 15.023), powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_MFD1_PWR, {-0.383, 2.153, 15.090}, powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_MFD2_PWR, {-0.383, 1.922, 15.023}, powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_MFD3_PWR, {-0.114, 2.037, 15.058}, powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_MFD4_PWR, { 0.155, 2.153, 15.090}, powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_MFD5_PWR, { 0.155, 1.922, 15.023}, powerButtonRadius); // register+activate MFD brightness buttons oapiVCRegisterArea (AID_MFD1_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); @@ -1899,11 +1899,11 @@ void Atlantis::RegisterVC_CntMFD () oapiVCRegisterArea (AID_MFD3_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_MFD4_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); oapiVCRegisterArea (AID_MFD5_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD1_BRT, _V(-0.162,2.1605,15.090), _V(-0.147,2.1605,15.090), _V(-0.162,2.1455,15.090), _V(-0.147,2.1455,15.090)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD2_BRT, _V(-0.162,1.9295,15.023), _V(-0.147,1.9295,15.023), _V(-0.162,1.9145,15.023), _V(-0.147,1.9145,15.023)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD3_BRT, _V(0.107,2.0445,15.058), _V(0.122,2.0445,15.058), _V(0.107,2.0295,15.058), _V(0.122,2.0295,15.058)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD4_BRT, _V(0.376,2.1605,15.090), _V(0.391,2.1605,15.090), _V(0.376,2.1455,15.090), _V(0.391,2.1455,15.090)); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFD5_BRT, _V(0.376,1.9295,15.023), _V(0.391,1.9295,15.023), _V(0.376,1.9145,15.023), _V(0.391,1.9145,15.023)); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD1_BRT, {-0.162,2.1605,15.090}, {-0.147,2.1605,15.090}, {-0.162,2.1455,15.090}, {-0.147,2.1455,15.090}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD2_BRT, {-0.162,1.9295,15.023}, {-0.147,1.9295,15.023}, {-0.162,1.9145,15.023}, {-0.147,1.9145,15.023}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD3_BRT, {0.107,2.0445,15.058}, {0.122,2.0445,15.058}, {0.107,2.0295,15.058}, {0.122,2.0295,15.058}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD4_BRT, {0.376,2.1605,15.090}, {0.391,2.1605,15.090}, {0.376,2.1455,15.090}, {0.391,2.1455,15.090}); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFD5_BRT, {0.376,1.9295,15.023}, {0.391,1.9295,15.023}, {0.376,1.9145,15.023}, {0.391,1.9145,15.023}); } // -------------------------------------------------------------- @@ -1915,16 +1915,16 @@ void Atlantis::RegisterVC_AftMFD () // register+activate aft MFD function buttons SURFHANDLE tex1 = oapiGetTextureHandle (hOrbiterVCMesh, 7); oapiVCRegisterArea (AID_MFDA_BUTTONS, _R(0,127,255,140), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFDA_BUTTONS, _V(1.3862,2.2570,13.8686), _V(1.3862,2.2570,13.6894), _V(1.3678,2.2452,13.8686), _V(1.3678,2.2452,13.6894)); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFDA_BUTTONS, {1.3862,2.2570,13.8686}, {1.3862,2.2570,13.6894}, {1.3678,2.2452,13.8686}, {1.3678,2.2452,13.6894}); // register+activate MFD power button const double powerButtonRadius = 0.0075; // radius of power button on each MFD oapiVCRegisterArea (AID_MFDA_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Spherical(AID_MFDA_PWR, _V(1.3929,2.2632,13.8947), powerButtonRadius); + oapiVCSetAreaClickmode_Spherical(AID_MFDA_PWR, {1.3929,2.2632,13.8947}, powerButtonRadius); // register+activate MFD brightness buttons oapiVCRegisterArea (AID_MFDA_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Quadrilateral (AID_MFDA_BRT, _V(1.4024,2.2675,13.6736), _V(1.4024,2.2675,13.6586), _V(1.3893,2.2590,13.6736), _V(1.3893,2.2590,13.6586)); + oapiVCSetAreaClickmode_Quadrilateral (AID_MFDA_BRT, {1.4024,2.2675,13.6736}, {1.4024,2.2675,13.6586}, {1.3893,2.2590,13.6736}, {1.3893,2.2590,13.6586}); } // -------------------------------------------------------------- @@ -1976,10 +1976,10 @@ bool Atlantis::clbkLoadVC (int id) switch (id) { case 0: // commander position - SetCameraOffset (_V(-0.67,2.55,14.4)); - SetCameraDefaultDirection (_V(0,0,1)); - SetCameraMovement (_V(0,0,0.3), 0, 0, _V(-0.3,0,0), 75*RAD, -5*RAD, _V(0.3,0,0), -20*RAD, -27*RAD); - huds.hudcnt = _V(-0.671257, 2.523535, 14.969); + SetCameraOffset ({-0.67,2.55,14.4}); + SetCameraDefaultDirection ({0,0,1}); + SetCameraMovement ({0,0,0.3}, 0, 0, {-0.3,0,0}, 75*RAD, -5*RAD, {0.3,0,0}, -20*RAD, -27*RAD); + huds.hudcnt = {-0.671257, 2.523535, 14.969}; oapiVCSetNeighbours (-1, 1, -1, 2); RegisterVC_CdrMFD (); // activate commander MFD controls @@ -1988,10 +1988,10 @@ bool Atlantis::clbkLoadVC (int id) ok = true; break; case 1: // pilot position - SetCameraOffset (_V(0.67,2.55,14.4)); - SetCameraDefaultDirection (_V(0,0,1)); - SetCameraMovement (_V(0,0,0.3), 0, 0, _V(-0.3,0,0), 20*RAD, -27*RAD, _V(0.3,0,0), -75*RAD, -5*RAD); - huds.hudcnt = _V(0.671257, 2.523535, 14.969); + SetCameraOffset ({0.67,2.55,14.4}); + SetCameraDefaultDirection ({0,0,1}); + SetCameraMovement ({0,0,0.3}, 0, 0, {-0.3,0,0}, 20*RAD, -27*RAD, {0.3,0,0}, -75*RAD, -5*RAD); + huds.hudcnt = {0.671257, 2.523535, 14.969}; oapiVCSetNeighbours (0, -1, -1, 2); RegisterVC_PltMFD (); // activate pilot MFD controls @@ -2000,9 +2000,9 @@ bool Atlantis::clbkLoadVC (int id) ok = true; break; case 2: // payload view position - SetCameraOffset (_V(0.4,3.15,13.0)); - SetCameraDefaultDirection (_V(0,0,-1)); - SetCameraMovement (_V(0,-0.1,-0.1), 0, 80.0*RAD, _V(0.3,-0.3,0.15), 60.0*RAD, -50.0*RAD, _V(-0.8,0,0), 0, 0); + SetCameraOffset ({0.4,3.15,13.0}); + SetCameraDefaultDirection ({0,0,-1}); + SetCameraMovement ({0,-0.1,-0.1}, 0, 80.0*RAD, {0.3,-0.3,0.15}, 60.0*RAD, -50.0*RAD, {-0.8,0,0}, 0, 0); oapiVCSetNeighbours (1, 0, -1, 0); RegisterVC_AftMFD (); // activate aft MFD controls diff --git a/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp b/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp index e22b69bcd..dbbfa6147 100644 --- a/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp +++ b/Src/Vessel/Atlantis/Atlantis/PlBayOp.cpp @@ -365,7 +365,7 @@ void PayloadBayOp::RegisterVC () // register the complete panel for mouse events oapiVCRegisterArea (AID_R13L, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN); - oapiVCSetAreaClickmode_Quadrilateral (AID_R13L, _V(1.3543,2.23023,12.8581), _V(1.3543,2.23023,12.5486), _V(1.0868,2.0547,12.8581), _V(1.0868,2.0547,12.5486)); + oapiVCSetAreaClickmode_Quadrilateral (AID_R13L, {1.3543,2.23023,12.8581}, {1.3543,2.23023,12.5486}, {1.0868,2.0547,12.8581}, {1.0868,2.0547,12.5486}); // register the talkbacks oapiVCRegisterArea (AID_R13L_TKBK1, _R( 0,0, 32,18), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_NONE, tkbk_tex); diff --git a/Src/Vessel/Atlantis/Atlantis_SRB/Atlantis_SRB.cpp b/Src/Vessel/Atlantis/Atlantis_SRB/Atlantis_SRB.cpp index 280adc3c4..aa1dc35e5 100644 --- a/Src/Vessel/Atlantis/Atlantis_SRB/Atlantis_SRB.cpp +++ b/Src/Vessel/Atlantis/Atlantis_SRB/Atlantis_SRB.cpp @@ -25,19 +25,19 @@ static const int ntdvtx = 13; static const TOUCHDOWNVTX tdvtx[ntdvtx] = { - {_V( 0, 2.5, -21.18), 1e9, 1e7, 0.3 }, - {_V( 2.1651,-1.25,-21.18), 1e9, 1e7, 0.3 }, - {_V(-2.1651,-1.25,-21.18), 1e9, 1e7, 0.3 }, - {_V( 2.1651, 1.25,-21.18), 1e9, 1e7, 0.3 }, - {_V( 0, -2.5 ,-21.18), 1e9, 1e7, 0.3 }, - {_V(-2.1651, 1.25,-21.18), 1e9, 1e7, 0.3 }, - {_V( 0, 1.85, 18.95), 1e9, 1e7, 0.3 }, - {_V( 1.6021,-0.925,18.95), 1e9, 1e7, 0.3 }, - {_V(-1.6021,-0.925,18.95), 1e9, 1e7, 0.3 }, - {_V( 1.6021, 0.925,18.95), 1e9, 1e7, 0.3 }, - {_V( 0, -1.85, 18.95), 1e9, 1e7, 0.3 }, - {_V(-1.6021, 0.925,18.95), 1e9, 1e7, 0.3 }, - {_V( 0, 0, 23.78), 1e9, 1e7, 0.3 } + {{ 0, 2.5, -21.18}, 1e9, 1e7, 0.3 }, + {{ 2.1651,-1.25,-21.18}, 1e9, 1e7, 0.3 }, + {{-2.1651,-1.25,-21.18}, 1e9, 1e7, 0.3 }, + {{ 2.1651, 1.25,-21.18}, 1e9, 1e7, 0.3 }, + {{ 0, -2.5 ,-21.18}, 1e9, 1e7, 0.3 }, + {{-2.1651, 1.25,-21.18}, 1e9, 1e7, 0.3 }, + {{ 0, 1.85, 18.95}, 1e9, 1e7, 0.3 }, + {{ 1.6021,-0.925,18.95}, 1e9, 1e7, 0.3 }, + {{-1.6021,-0.925,18.95}, 1e9, 1e7, 0.3 }, + {{ 1.6021, 0.925,18.95}, 1e9, 1e7, 0.3 }, + {{ 0, -1.85, 18.95}, 1e9, 1e7, 0.3 }, + {{-1.6021, 0.925,18.95}, 1e9, 1e7, 0.3 }, + {{ 0, 0, 23.78}, 1e9, 1e7, 0.3 } }; // Constructor @@ -153,16 +153,16 @@ void Atlantis_SRB::clbkSetClassCaps (FILEHANDLE cfg) SetSize (23.0); SetEmptyMass (SRB_EMPTY_MASS); SetCW (0.1, 0.3, 1.4, 1.4); - SetCrossSections (_V(162.1,162.1,26.6)); - SetRotDrag (_V(0.7,0.7,0.1)); - SetPMI (_V(154.3,154.3,1.83)); + SetCrossSections ({162.1,162.1,26.6}); + SetRotDrag ({0.7,0.7,0.1}); + SetPMI ({154.3,154.3,1.83}); //SetGravityGradientDamping (10.0); SetTouchdownPoints (tdvtx, ntdvtx); SetLiftCoeffFunc (0); // ************************* docking port ************************************** - CreateDock (_V(1.95,0,5),_V(1,0,0),_V(0,0,1)); // ET attachment + CreateDock ({1.95,0,5},{1,0,0},{0,0,1}); // ET attachment // ************************* propellant specs ********************************** @@ -171,21 +171,21 @@ void Atlantis_SRB::clbkSetClassCaps (FILEHANDLE cfg) // *********************** thruster definitions ******************************** // main engine - th_main = CreateThruster (_V(0,0,-21), THRUSTGIMBAL_LAUNCH, SRB_THRUST, ph_main, SRB_ISP0, SRB_ISP1); + th_main = CreateThruster ({0,0,-21}, THRUSTGIMBAL_LAUNCH, SRB_THRUST, ph_main, SRB_ISP0, SRB_ISP1); SURFHANDLE tex = oapiRegisterExhaustTexture ((char*)"Exhaust2"); srb_exhaust.tex = oapiRegisterParticleTexture ((char*)"Contrail2"); AddExhaust (th_main, 16.0, 2.0, tex); - AddExhaustStream (th_main, _V(0,0,-30), &srb_contrail); - AddExhaustStream (th_main, _V(0,0,-25), &srb_exhaust); + AddExhaustStream (th_main, {0,0,-30}, &srb_contrail); + AddExhaustStream (th_main, {0,0,-25}, &srb_exhaust); // separation bolts - th_bolt = CreateThruster (_V(0,0,3.0), _V(-1,0,0), 3e6, ph_main, 1e7); + th_bolt = CreateThruster ({0,0,3.0}, {-1,0,0}, 3e6, ph_main, 1e7); // for simplicity, the separation bolts directly use SRB propellant. We give // them an insanely high ISP to avoid significant propellant drainage - AddExhaust (th_bolt, 0.7, 0.1, _V(2.1,0,-8), _V(-1,0,0)); - AddExhaust (th_bolt, 0.7, 0.1, _V(2.1,0,11), _V(-1,0,0)); - AddExhaustStream (th_bolt, _V(2.1,0,0), &srb_bolt); + AddExhaust (th_bolt, 0.7, 0.1, {2.1,0,-8}, {-1,0,0}); + AddExhaust (th_bolt, 0.7, 0.1, {2.1,0,11}, {-1,0,0}); + AddExhaustStream (th_bolt, {2.1,0,0}, &srb_bolt); // ************************ visual parameters ********************************** @@ -212,7 +212,7 @@ void Atlantis_SRB::clbkPostCreation () } } if (srbpos != SRB_UNDEFINED) - SetThrusterDir(th_bolt, srbpos == SRB_LEFT ? _V(-0.4,-0.9165,0) : _V(-0.4,0.9165,0)); + SetThrusterDir(th_bolt, srbpos == SRB_LEFT ? VECTOR3{-0.4,-0.9165,0} : VECTOR3{-0.4,0.9165,0}); } // Read current state @@ -260,7 +260,7 @@ void Atlantis_SRB::clbkPostStep (double simt, double simdt, double mjd) double dg_max = simdt*SRB_GIMBAL_SPEED; VECTOR3 gimbalcur = GetThrustGimbal(); VECTOR3 gdiff = gimbalcmd-gimbalcur; - double dg = length(gdiff); + double dg = len(gdiff); if (dg > dg_max) { gdiff *= dg_max/dg; } else { diff --git a/Src/Vessel/Atlantis/Atlantis_Tank/Atlantis_Tank.cpp b/Src/Vessel/Atlantis/Atlantis_Tank/Atlantis_Tank.cpp index 0161d073a..e190e1973 100644 --- a/Src/Vessel/Atlantis/Atlantis_Tank/Atlantis_Tank.cpp +++ b/Src/Vessel/Atlantis/Atlantis_Tank/Atlantis_Tank.cpp @@ -19,21 +19,21 @@ static const int ntdvtx = 15; static const TOUCHDOWNVTX tdvtx[ntdvtx] = { - {_V( 0, 5.85, 3.1 ), 1e9, 1e7, 0.3 }, - {_V( 2.4, 5.1, -21.3 ), 1e9, 1e7, 0.3 }, - {_V(-2.4, 5.1, -21.3 ), 1e9, 1e7, 0.3 }, - {_V( 4.2, 0, -21 ), 1e9, 1e7, 0.3 }, - {_V( 2.1,-3.637,-21 ), 1e9, 1e7, 0.3 }, - {_V(-2.1,-3.637,-21 ), 1e9, 1e7, 0.3 }, - {_V(-4.2, 0, -21 ), 1e9, 1e7, 0.3 }, - {_V( 4.2, 0, 15 ), 1e9, 1e7, 0.3 }, - {_V( 2.1,-3.637,15 ), 1e9, 1e7, 0.3 }, - {_V(-2.1,-3.637,15 ), 1e9, 1e7, 0.3 }, - {_V(-4.2, 0, 15 ), 1e9, 1e7, 0.3 }, - {_V(-2.1, 3.637,15 ), 1e9, 1e7, 0.3 }, - {_V( 2.1, 3.637,15 ), 1e9, 1e7, 0.3 }, - {_V( 0, 0, -23.57), 1e9, 1e7, 0.3 }, - {_V( 0, 0, 23.57), 1e9, 1e7, 0.3 } + {{ 0, 5.85, 3.1 }, 1e9, 1e7, 0.3 }, + {{ 2.4, 5.1, -21.3 }, 1e9, 1e7, 0.3 }, + {{-2.4, 5.1, -21.3 }, 1e9, 1e7, 0.3 }, + {{ 4.2, 0, -21 }, 1e9, 1e7, 0.3 }, + {{ 2.1,-3.637,-21 }, 1e9, 1e7, 0.3 }, + {{-2.1,-3.637,-21 }, 1e9, 1e7, 0.3 }, + {{-4.2, 0, -21 }, 1e9, 1e7, 0.3 }, + {{ 4.2, 0, 15 }, 1e9, 1e7, 0.3 }, + {{ 2.1,-3.637,15 }, 1e9, 1e7, 0.3 }, + {{-2.1,-3.637,15 }, 1e9, 1e7, 0.3 }, + {{-4.2, 0, 15 }, 1e9, 1e7, 0.3 }, + {{-2.1, 3.637,15 }, 1e9, 1e7, 0.3 }, + {{ 2.1, 3.637,15 }, 1e9, 1e7, 0.3 }, + {{ 0, 0, -23.57}, 1e9, 1e7, 0.3 }, + {{ 0, 0, 23.57}, 1e9, 1e7, 0.3 } }; // ============================================================== @@ -52,9 +52,9 @@ Atlantis_Tank::Atlantis_Tank (OBJHANDLE hObj) hProp = CreatePropellantResource (TANK_MAX_PROPELLANT_MASS); // docking ports - CreateDock (_V(0,5.5,-5), _V(0,1,0), _V(0,0,1)); // orbiter attachment - CreateDock (_V(-4.25,0,-6.4), _V(-1,0,0), _V(0,0,1)); // left SRB attachment - CreateDock (_V( 4.25,0,-6.4), _V( 1,0,0), _V(0,0,1)); // right SRB attachment + CreateDock ({0,5.5,-5}, {0,1,0}, {0,0,1}); // orbiter attachment + CreateDock ({-4.25,0,-6.4}, {-1,0,0}, {0,0,1}); // left SRB attachment + CreateDock ({ 4.25,0,-6.4}, { 1,0,0}, {0,0,1}); // right SRB attachment // by default, disable orbiter and SRB connectors hDockOrbiter = NULL; @@ -107,7 +107,7 @@ void Atlantis_Tank::clbkSetClassCaps (FILEHANDLE cfg) // since the Tank doesn't define a 'cockpit' SetCOG_elev (-5.0); - //SetTouchdownPoints (_V(0,9,3), _V(-1,1,-3), _V(1,1,-3)); + //SetTouchdownPoints ({0,9,3}, {-1,1,-3}, {1,1,-3}); SetTouchdownPoints (tdvtx, ntdvtx); SetLiftCoeffFunc (0); @@ -150,7 +150,7 @@ Atlantis_SRB *Atlantis_Tank::GetSRB (int which) const void Atlantis_Tank::EnableOrbiterConnector () { //if (!hDockOrbiter) { - // hDockOrbiter = CreateDock (_V(0.0, 4.64, -9.285), _V(0,1,0), _V(1,0,0)); + // hDockOrbiter = CreateDock ({0.0, 4.64, -9.285}, {0,1,0}, {1,0,0}); //} } @@ -192,7 +192,7 @@ void Atlantis_Tank::SetSRBGimbal (const VECTOR3 &angle) const VECTOR3 Atlantis_Tank::GetSRBThrustDir (int which) const { if (pSRB[which]) return pSRB[which]->GetThrustGimbal(); - else return _V(0,0,1); + else return {0,0,1}; } bool Atlantis_Tank::IgniteSRBs () const @@ -218,7 +218,7 @@ void Atlantis_Tank::SeparateSRBs () for (int i = 0; i < 2; i++) { if (pSRB[i]) { const double angle = 0.25*PI; - VECTOR3 dir = _V(0.0, i ? -0.04 : 0.04, 0.9992); + VECTOR3 dir = {0.0, i ? -0.04 : 0.04, 0.9992}; Undock (i+1); pSRB[i]->CmdThrustGimbal (dir); // set SRB gimbals for safe separation pSRB[i]->FireBolt(); diff --git a/Src/Vessel/DeltaGlider/AerodynSubsys.cpp b/Src/Vessel/DeltaGlider/AerodynSubsys.cpp index 114396f8d..1bbcee667 100644 --- a/Src/Vessel/DeltaGlider/AerodynSubsys.cpp +++ b/Src/Vessel/DeltaGlider/AerodynSubsys.cpp @@ -226,14 +226,14 @@ Airbrake::Airbrake (AerodynCtrlSubsystem *_subsys) static UINT LRudderGrp[2] = {GRP_LRudder1,GRP_LRudder2}; static UINT UpperBrakeGrp[4] = {GRP_RUAileron1,GRP_LUAileron1,GRP_LUAileron2,GRP_RUAileron2}; static MGROUP_ROTATE UpperBrake (0, UpperBrakeGrp, 4, - _V(0,-0.4,-6.0), _V(1,0,0), (float)(50*RAD)); + {0,-0.4,-6.0}, {1,0,0}, (float)(50*RAD)); static UINT LowerBrakeGrp[4] = {GRP_LLAileron1,GRP_RLAileron1,GRP_LLAileron2,GRP_RLAileron2}; static MGROUP_ROTATE LowerBrake (0, LowerBrakeGrp, 4, - _V(0,-0.4,-6.0), _V(1,0,0), (float)(-50*RAD)); + {0,-0.4,-6.0}, {1,0,0}, (float)(-50*RAD)); static MGROUP_ROTATE RRudderBrake (0, RRudderGrp, 2, - _V( 8.668,0.958,-6.204), _V( 0.143,0.975,-0.172), (float)( 25*RAD)); + { 8.668,0.958,-6.204}, { 0.143,0.975,-0.172}, (float)( 25*RAD)); static MGROUP_ROTATE LRudderBrake (0, LRudderGrp, 2, - _V(-8.668,0.958,-6.204), _V(-0.143,0.975,-0.172), (float)(-25*RAD)); + {-8.668,0.958,-6.204}, {-0.143,0.975,-0.172}, (float)(-25*RAD)); anim_brake = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_brake, 0, 1, &UpperBrake); diff --git a/Src/Vessel/DeltaGlider/DeltaGlider.cpp b/Src/Vessel/DeltaGlider/DeltaGlider.cpp index 8d5e710f8..fa3d74981 100644 --- a/Src/Vessel/DeltaGlider/DeltaGlider.cpp +++ b/Src/Vessel/DeltaGlider/DeltaGlider.cpp @@ -55,36 +55,36 @@ static HELPCONTEXT g_hc = { static const DWORD ntdvtx_geardown = 13; static TOUCHDOWNVTX tdvtx_geardown[ntdvtx_geardown] = { - {_V( 0 ,-2.57,10 ), 1e6, 1e5, 1.6, 0.1}, - {_V(-3.5 ,-2.57,-1 ), 1e6, 1e5, 3.0, 0.2}, - {_V( 3.5 ,-2.57,-1 ), 1e6, 1e5, 3.0, 0.2}, - {_V(-8.5 ,-0.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V( 8.5 ,-0.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V(-8.5 ,-0.4 ,-3 ), 1e7, 1e5, 3.0}, - {_V( 8.5 ,-0.4 ,-3 ), 1e7, 1e5, 3.0}, - {_V(-8.85, 2.3 ,-5.05), 1e7, 1e5, 3.0}, - {_V( 8.85, 2.3 ,-5.05), 1e7, 1e5, 3.0}, - {_V(-8.85, 2.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V( 8.85, 2.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V( 0 , 2 , 6.2 ), 1e7, 1e5, 3.0}, - {_V( 0 ,-0.6 ,10.65), 1e7, 1e5, 3.0} + {{ 0 ,-2.57,10 }, 1e6, 1e5, 1.6, 0.1}, + {{-3.5 ,-2.57,-1 }, 1e6, 1e5, 3.0, 0.2}, + {{ 3.5 ,-2.57,-1 }, 1e6, 1e5, 3.0, 0.2}, + {{-8.5 ,-0.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{ 8.5 ,-0.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{-8.5 ,-0.4 ,-3 }, 1e7, 1e5, 3.0}, + {{ 8.5 ,-0.4 ,-3 }, 1e7, 1e5, 3.0}, + {{-8.85, 2.3 ,-5.05}, 1e7, 1e5, 3.0}, + {{ 8.85, 2.3 ,-5.05}, 1e7, 1e5, 3.0}, + {{-8.85, 2.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{ 8.85, 2.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{ 0 , 2 , 6.2 }, 1e7, 1e5, 3.0}, + {{ 0 ,-0.6 ,10.65}, 1e7, 1e5, 3.0} }; static const DWORD ntdvtx_gearup = 13; static TOUCHDOWNVTX tdvtx_gearup[ntdvtx_gearup] = { - {_V( 0 ,-1.5 ,9), 1e7, 1e5, 3.0, 3.0}, - {_V(-6 ,-0.8 ,-5), 1e7, 1e5, 3.0, 3.0}, - {_V( 3 ,-1.2 ,-5), 1e7, 1e5, 3.0, 3.0}, - {_V(-8.5 ,-0.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V( 8.5 ,-0.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V(-8.5 ,-0.4 ,-3 ), 1e7, 1e5, 3.0}, - {_V( 8.5 ,-0.4 ,-3 ), 1e7, 1e5, 3.0}, - {_V(-8.85, 2.3 ,-5.05), 1e7, 1e5, 3.0}, - {_V( 8.85, 2.3 ,-5.05), 1e7, 1e5, 3.0}, - {_V(-8.85, 2.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V( 8.85, 2.3 ,-7.05), 1e7, 1e5, 3.0}, - {_V( 0 , 2 , 6.2 ), 1e7, 1e5, 3.0}, - {_V( 0 ,-0.6 ,10.65), 1e7, 1e5, 3.0} + {{ 0 ,-1.5 ,9}, 1e7, 1e5, 3.0, 3.0}, + {{-6 ,-0.8 ,-5}, 1e7, 1e5, 3.0, 3.0}, + {{ 3 ,-1.2 ,-5}, 1e7, 1e5, 3.0, 3.0}, + {{-8.5 ,-0.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{ 8.5 ,-0.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{-8.5 ,-0.4 ,-3 }, 1e7, 1e5, 3.0}, + {{ 8.5 ,-0.4 ,-3 }, 1e7, 1e5, 3.0}, + {{-8.85, 2.3 ,-5.05}, 1e7, 1e5, 3.0}, + {{ 8.85, 2.3 ,-5.05}, 1e7, 1e5, 3.0}, + {{-8.85, 2.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{ 8.85, 2.3 ,-7.05}, 1e7, 1e5, 3.0}, + {{ 0 , 2 , 6.2 }, 1e7, 1e5, 3.0}, + {{ 0 ,-0.6 ,10.65}, 1e7, 1e5, 3.0} }; // ============================================================== @@ -242,10 +242,10 @@ void DeltaGlider::DefineAnimations () // ***** Rudder animation ***** static UINT RRudderGrp[2] = {GRP_RRudder1,GRP_RRudder2}; static MGROUP_ROTATE RRudder (0, RRudderGrp, 2, - _V( 8.668,0.958,-6.204), _V( 0.143,0.975,-0.172), (float)(-60*RAD)); + { 8.668,0.958,-6.204}, { 0.143,0.975,-0.172}, (float)(-60*RAD)); static UINT LRudderGrp[2] = {GRP_LRudder1,GRP_LRudder2}; static MGROUP_ROTATE LRudder (0, LRudderGrp, 2, - _V(-8.668,0.958,-6.204), _V(-0.143,0.975,-0.172), (float)(-60*RAD)); + {-8.668,0.958,-6.204}, {-0.143,0.975,-0.172}, (float)(-60*RAD)); anim_rudder = CreateAnimation (0.5); AddAnimationComponent (anim_rudder, 0, 1, &RRudder); AddAnimationComponent (anim_rudder, 0, 1, &LRudder); @@ -253,26 +253,26 @@ void DeltaGlider::DefineAnimations () // ***** Elevator animation ***** static UINT ElevatorGrp[8] = {GRP_LUAileron1,GRP_LUAileron2,GRP_LLAileron1,GRP_LLAileron2,GRP_RUAileron1,GRP_RUAileron2,GRP_RLAileron1,GRP_RLAileron2}; static MGROUP_ROTATE Elevator (0, ElevatorGrp, 8, - _V(0,-0.4,-6.0), _V(1,0,0), (float)(40*RAD)); + {0,-0.4,-6.0}, {1,0,0}, (float)(40*RAD)); anim_elevator = CreateAnimation (0.5); AddAnimationComponent (anim_elevator, 0, 1, &Elevator); // ***** Elevator trim animation ***** static MGROUP_ROTATE ElevatorTrim (0, ElevatorGrp, 8, - _V(0,-0.4,-6.0), _V(1,0,0), (float)(10*RAD)); + {0,-0.4,-6.0}, {1,0,0}, (float)(10*RAD)); anim_elevatortrim = CreateAnimation (0.5); AddAnimationComponent (anim_elevatortrim, 0, 1, &ElevatorTrim); // ***** Aileron animation ***** static UINT LAileronGrp[4] = {GRP_LUAileron1,GRP_LUAileron2,GRP_LLAileron1,GRP_LLAileron2}; static MGROUP_ROTATE LAileron (0, LAileronGrp, 4, - _V(0,-0.4,-6.0), _V(1,0,0), (float)(-20*RAD)); + {0,-0.4,-6.0}, {1,0,0}, (float)(-20*RAD)); anim_laileron = CreateAnimation (0.5); AddAnimationComponent (anim_laileron, 0, 1, &LAileron); static UINT RAileronGrp[4] = {GRP_RUAileron1,GRP_RUAileron2,GRP_RLAileron1,GRP_RLAileron2}; static MGROUP_ROTATE RAileron (0, RAileronGrp, 4, - _V(0,-0.4,-6.0), _V(1,0,0), (float)(20*RAD)); + {0,-0.4,-6.0}, {1,0,0}, (float)(20*RAD)); anim_raileron = CreateAnimation (0.5); AddAnimationComponent (anim_raileron, 0, 1, &RAileron); } @@ -612,7 +612,7 @@ void DeltaGlider::ApplyDamage () { double balance = (rwingstatus-lwingstatus)*3.0; double surf = (rwingstatus+lwingstatus)*35.0 + 20.0; - EditAirfoil (hwing, 0x09, _V(balance,0,-0.3), 0, 0, surf, 0); + EditAirfoil (hwing, 0x09, {balance,0,-0.3}, 0, 0, surf, 0); if (rwingstatus < 1 || lwingstatus < 1) ssys_failure->MWSActivate(); @@ -624,11 +624,11 @@ void DeltaGlider::RepairDamage () { int i; lwingstatus = rwingstatus = 1.0; - EditAirfoil (hwing, 0x09, _V(0,0,-0.3), 0, 0, 90.0, 0); + EditAirfoil (hwing, 0x09, {0,0,-0.3}, 0, 0, 90.0, 0); if (!hlaileron) - hlaileron = CreateControlSurface2 (AIRCTRL_AILERON, 0.3, 1.5, _V( 7.5,0,-7.2), AIRCTRL_AXIS_XPOS, anim_raileron); + hlaileron = CreateControlSurface2 (AIRCTRL_AILERON, 0.3, 1.5, { 7.5,0,-7.2}, AIRCTRL_AXIS_XPOS, anim_raileron); if (!hraileron) - hraileron = CreateControlSurface2 (AIRCTRL_AILERON, 0.3, 1.5, _V(-7.5,0,-7.2), AIRCTRL_AXIS_XNEG, anim_laileron); + hraileron = CreateControlSurface2 (AIRCTRL_AILERON, 0.3, 1.5, {-7.5,0,-7.2}, AIRCTRL_AXIS_XNEG, anim_laileron); for (i = 0; i < 4; i++) aileronfail[i] = false; ssys_pressurectrl->RepairDamage (); @@ -885,16 +885,16 @@ void DeltaGlider::clbkSetClassCaps (FILEHANDLE cfg) VECTOR3 r[2] = {{0,0,6}, {0,0,-4}}; SetSize (10.0); SetVisibilityLimit (7.5e-4, 1.5e-3); - SetAlbedoRGB (_V(0.77,0.20,0.13)); + SetAlbedoRGB ({0.77,0.20,0.13}); SetGravityGradientDamping (20.0); SetCW (0.09, 0.09, 2, 1.4); SetWingAspect (0.7); SetWingEffectiveness (2.5); - SetCrossSections (_V(53.0,186.9,25.9)); + SetCrossSections ({53.0,186.9,25.9}); SetMaxWheelbrakeForce (2e5); - SetPMI (_V(15.5,22.1,7.7)); + SetPMI ({15.5,22.1,7.7}); - SetDockParams (_V(0,-0.49,10.076), _V(0,0,1), _V(0,1,0)); + SetDockParams ({0,-0.49,10.076}, {0,0,1}, {0,1,0}); SetTouchdownPoints (tdvtx_geardown, ntdvtx_geardown); SetNosewheelSteering (true); bGearIsDown = true; @@ -946,34 +946,34 @@ void DeltaGlider::clbkSetClassCaps (FILEHANDLE cfg) }; // main thrusters - th_main[0] = CreateThruster (_V(-1,0.0,-7.7), _V(0,0,1), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale); - th_main[1] = CreateThruster (_V( 1,0.0,-7.7), _V(0,0,1), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale); + th_main[0] = CreateThruster ({-1,0.0,-7.7}, {0,0,1}, MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale); + th_main[1] = CreateThruster ({ 1,0.0,-7.7}, {0,0,1}, MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale); thg_main = CreateThrusterGroup (th_main, 2, THGROUP_MAIN); EXHAUSTSPEC es_main[2] = { {th_main[0], NULL, NULL, NULL, 12, 1, 0, 0.1, NULL}, {th_main[1], NULL, NULL, NULL, 12, 1, 0, 0.1, NULL} }; for (i = 0; i < 2; i++) AddExhaust (es_main+i); - AddExhaustStream (th_main[0], _V(-1,0,-15), &contrail); - AddExhaustStream (th_main[1], _V( 1,0,-15), &contrail); - AddExhaustStream (th_main[0], _V(-1,0,-10), &exhaust_main); - AddExhaustStream (th_main[1], _V( 1,0,-10), &exhaust_main); + AddExhaustStream (th_main[0], {-1,0,-15}, &contrail); + AddExhaustStream (th_main[1], { 1,0,-15}, &contrail); + AddExhaustStream (th_main[0], {-1,0,-10}, &exhaust_main); + AddExhaustStream (th_main[1], { 1,0,-10}, &exhaust_main); //DWORD i = GetGroupThrusterCount (THGROUP_MAIN); // retro thrusters // note that we have to tilt retros slightly downwards to avoid inducing // an angular momentum, since they are mounted below the level of CG. // This also means that retros will induce an upward linear component. - th_retro[0] = CreateThruster (_V(-3,-0.236,5.6), _V(0,0.04210548,-0.99911317), MAX_RETRO_THRUST, ph_main, ISP, ISP*ispscale); - th_retro[1] = CreateThruster (_V( 3,-0.236,5.6), _V(0,0.04210548,-0.99911317), MAX_RETRO_THRUST, ph_main, ISP, ISP*ispscale); + th_retro[0] = CreateThruster ({-3,-0.236,5.6}, {0,0.04210548,-0.99911317}, MAX_RETRO_THRUST, ph_main, ISP, ISP*ispscale); + th_retro[1] = CreateThruster ({ 3,-0.236,5.6}, {0,0.04210548,-0.99911317}, MAX_RETRO_THRUST, ph_main, ISP, ISP*ispscale); thg_retro = CreateThrusterGroup (th_retro, 2, THGROUP_RETRO); EXHAUSTSPEC es_retro[2] = {{th_retro[0], NULL, NULL, NULL, 3, 0.4, 0, 0.1, NULL}, {th_retro[1], NULL, NULL, NULL, 3, 0.4, 0, 0.1, NULL}}; for (i = 0; i < 2; i++) AddExhaust (es_retro+i); // hover thrusters - th_hover[0] = CreateThruster (_V(0,0,3), _V(0,1,0), MAX_HOVER_THRUST[modelidx], ph_main, ISP, ISP*ispscale); - th_hover[1] = CreateThruster (_V(-3,0,-4.55), _V(0,1,0), 3.0/4.55*0.5*MAX_HOVER_THRUST[modelidx], ph_main, ISP, ISP*ispscale); - th_hover[2] = CreateThruster (_V( 3,0,-4.55), _V(0,1,0), 3.0/4.55*0.5*MAX_HOVER_THRUST[modelidx], ph_main, ISP, ISP*ispscale); + th_hover[0] = CreateThruster ({0,0,3}, {0,1,0}, MAX_HOVER_THRUST[modelidx], ph_main, ISP, ISP*ispscale); + th_hover[1] = CreateThruster ({-3,0,-4.55}, {0,1,0}, 3.0/4.55*0.5*MAX_HOVER_THRUST[modelidx], ph_main, ISP, ISP*ispscale); + th_hover[2] = CreateThruster ({ 3,0,-4.55}, {0,1,0}, 3.0/4.55*0.5*MAX_HOVER_THRUST[modelidx], ph_main, ISP, ISP*ispscale); thg_hover = CreateThrusterGroup (th_hover, 3, THGROUP_HOVER); VECTOR3 hoverp0 = {0,-1.5, 3}, hoverp1 = {-3,-1.3,-4.55}, hoverp2 = {3,-1.3,-4.55}, hoverd = {0,1,0}; EXHAUSTSPEC es_hover[3] = { @@ -982,92 +982,92 @@ void DeltaGlider::clbkSetClassCaps (FILEHANDLE cfg) {th_hover[2], NULL, &hoverp2, &hoverd, 6, 0.5, 0, 0.1, NULL, EXHAUST_CONSTANTPOS|EXHAUST_CONSTANTDIR} }; for (i = 0; i < 3; i++) AddExhaust (es_hover+i); - AddExhaustStream (th_hover[0], _V(0,-4,0), &contrail); - AddExhaustStream (th_hover[0], _V(0,-2,3), &exhaust_hover); - AddExhaustStream (th_hover[1], _V(-3,-2,-4.55), &exhaust_hover); - AddExhaustStream (th_hover[2], _V( 3,-2,-4.55), &exhaust_hover); + AddExhaustStream (th_hover[0], {0,-4,0}, &contrail); + AddExhaustStream (th_hover[0], {0,-2,3}, &exhaust_hover); + AddExhaustStream (th_hover[1], {-3,-2,-4.55}, &exhaust_hover); + AddExhaustStream (th_hover[2], { 3,-2,-4.55}, &exhaust_hover); // set of attitude thrusters (idealised). The arrangement is such that no angular // momentum is created in linear mode, and no linear momentum is created in rotational mode. THRUSTER_HANDLE th_att_rot[4], th_att_lin[4]; - th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 8), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[1] = th_att_lin[3] = CreateThruster (_V(0,0,-8), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[2] = th_att_lin[2] = CreateThruster (_V(0,0, 8), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-8), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[0] = th_att_lin[0] = CreateThruster ({0,0, 8}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[1] = th_att_lin[3] = CreateThruster ({0,0,-8}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[2] = th_att_lin[2] = CreateThruster ({0,0, 8}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[3] = th_att_lin[1] = CreateThruster ({0,0,-8}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_PITCHUP); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_PITCHDOWN); CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_UP); CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_DOWN); - AddExhaust (th_att_rot[0], 0.6, 0.078, _V( -0.816081, -0.616431, 9.594813 ), _V(0,-1,0)); - AddExhaust (th_att_rot[0], 0.6, 0.078, _V( 0.816081, -0.616431, 9.594813 ), _V(0,-1,0)); - AddExhaust (th_att_rot[1], 0.79, 0.103, _V( -0.120063, 0.409999, -7.357354 ), _V(0, 1,0)); - AddExhaust (th_att_rot[1], 0.79, 0.103, _V( 0.120063, 0.409999, -7.357354 ), _V(0, 1,0)); - AddExhaust (th_att_rot[2], 0.6, 0.078, _V( -0.816081, -0.35857, 9.594813 ), _V(0, 1,0)); - AddExhaust (th_att_rot[2], 0.6, 0.078, _V( 0.816081, -0.35857, 9.594813 ), _V(0, 1,0)); - AddExhaust (th_att_rot[3], 0.79, 0.103, _V( -0.120063, -0.409999, -7.357354 ), _V(0,-1,0)); - AddExhaust (th_att_rot[3], 0.79, 0.103, _V( 0.120063, -0.409999, -7.357354 ), _V(0,-1,0)); - - th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 6), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[1] = th_att_lin[3] = CreateThruster (_V(0,0,-6), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[2] = th_att_lin[2] = CreateThruster (_V(0,0, 6), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-6), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); + AddExhaust (th_att_rot[0], 0.6, 0.078, { -0.816081, -0.616431, 9.594813 }, {0,-1,0}); + AddExhaust (th_att_rot[0], 0.6, 0.078, { 0.816081, -0.616431, 9.594813 }, {0,-1,0}); + AddExhaust (th_att_rot[1], 0.79, 0.103, { -0.120063, 0.409999, -7.357354 }, {0, 1,0}); + AddExhaust (th_att_rot[1], 0.79, 0.103, { 0.120063, 0.409999, -7.357354 }, {0, 1,0}); + AddExhaust (th_att_rot[2], 0.6, 0.078, { -0.816081, -0.35857, 9.594813 }, {0, 1,0}); + AddExhaust (th_att_rot[2], 0.6, 0.078, { 0.816081, -0.35857, 9.594813 }, {0, 1,0}); + AddExhaust (th_att_rot[3], 0.79, 0.103, { -0.120063, -0.409999, -7.357354 }, {0,-1,0}); + AddExhaust (th_att_rot[3], 0.79, 0.103, { 0.120063, -0.409999, -7.357354 }, {0,-1,0}); + + th_att_rot[0] = th_att_lin[0] = CreateThruster ({0,0, 6}, {-1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[1] = th_att_lin[3] = CreateThruster ({0,0,-6}, { 1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[2] = th_att_lin[2] = CreateThruster ({0,0, 6}, { 1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[3] = th_att_lin[1] = CreateThruster ({0,0,-6}, {-1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_YAWLEFT); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_YAWRIGHT); CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_LEFT); CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_RIGHT); - AddExhaust (th_att_rot[0], 0.6, 0.078, _V( 0.888971, -0.488177, 9.3408 ), _V(1,0,0)); - AddExhaust (th_att_rot[1], 0.94, 0.122, _V( -2.029295, 0.182903, -6.043046 ), _V(-1,0,0)); - AddExhaust (th_att_rot[2], 0.6, 0.078, _V( -0.888971, -0.488177, 9.3408 ), _V(-1,0,0)); - AddExhaust (th_att_rot[3], 0.94, 0.122, _V( 2.029295, 0.182903, -6.043046 ), _V(1,0,0)); - - th_att_rot[0] = CreateThruster (_V( 6,0,0), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[1] = CreateThruster (_V(-6,0,0), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[2] = CreateThruster (_V(-6,0,0), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[3] = CreateThruster (_V( 6,0,0), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); + AddExhaust (th_att_rot[0], 0.6, 0.078, { 0.888971, -0.488177, 9.3408 }, {1,0,0}); + AddExhaust (th_att_rot[1], 0.94, 0.122, { -2.029295, 0.182903, -6.043046 }, {-1,0,0}); + AddExhaust (th_att_rot[2], 0.6, 0.078, { -0.888971, -0.488177, 9.3408 }, {-1,0,0}); + AddExhaust (th_att_rot[3], 0.94, 0.122, { 2.029295, 0.182903, -6.043046 }, {1,0,0}); + + th_att_rot[0] = CreateThruster ({ 6,0,0}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[1] = CreateThruster ({-6,0,0}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[2] = CreateThruster ({-6,0,0}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[3] = CreateThruster ({ 6,0,0}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_BANKLEFT); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_BANKRIGHT); - AddExhaust (th_att_rot[0], 1.03, 0.134, _V( -5.121185, -0.073903, 0.375386 ), _V(0, 1,0)); - AddExhaust (th_att_rot[1], 1.03, 0.134, _V( 5.121185, -0.654322, 0.375386 ), _V(0,-1,0)); - AddExhaust (th_att_rot[2], 1.03, 0.134, _V( 5.121185, -0.073903, 0.375386 ), _V(0, 1,0)); - AddExhaust (th_att_rot[3], 1.03, 0.134, _V( -5.121185, -0.654322, 0.375386 ), _V(0,-1,0)); + AddExhaust (th_att_rot[0], 1.03, 0.134, { -5.121185, -0.073903, 0.375386 }, {0, 1,0}); + AddExhaust (th_att_rot[1], 1.03, 0.134, { 5.121185, -0.654322, 0.375386 }, {0,-1,0}); + AddExhaust (th_att_rot[2], 1.03, 0.134, { 5.121185, -0.073903, 0.375386 }, {0, 1,0}); + AddExhaust (th_att_rot[3], 1.03, 0.134, { -5.121185, -0.654322, 0.375386 }, {0,-1,0}); - th_att_lin[0] = CreateThruster (_V(0,0,-7), _V(0,0, 1), 2*MAX_RCS_THRUST, ph_rcs, ISP); - th_att_lin[1] = CreateThruster (_V(0,0, 7), _V(0,0,-1), 2*MAX_RCS_THRUST, ph_rcs, ISP); + th_att_lin[0] = CreateThruster ({0,0,-7}, {0,0, 1}, 2*MAX_RCS_THRUST, ph_rcs, ISP); + th_att_lin[1] = CreateThruster ({0,0, 7}, {0,0,-1}, 2*MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_lin, 1, THGROUP_ATT_FORWARD); CreateThrusterGroup (th_att_lin+1, 1, THGROUP_ATT_BACK); - AddExhaust (th_att_lin[0], 0.6, 0.078, _V( 0.0, -0.228914, -7.462329 ), _V(0,0,-1)); - AddExhaust (th_att_lin[0], 0.6, 0.078, _V( 0.0, 0.229, -7.462329 ), _V(0,0,-1)); - AddExhaust (th_att_lin[1], 0.6, 0.078, _V( -0.817096, -0.488177, 9.729635 ), _V(0,0,1)); - AddExhaust (th_att_lin[1], 0.6, 0.078, _V( 0.817096, -0.488177, 9.729635 ), _V(0,0,1)); + AddExhaust (th_att_lin[0], 0.6, 0.078, { 0.0, -0.228914, -7.462329 }, {0,0,-1}); + AddExhaust (th_att_lin[0], 0.6, 0.078, { 0.0, 0.229, -7.462329 }, {0,0,-1}); + AddExhaust (th_att_lin[1], 0.6, 0.078, { -0.817096, -0.488177, 9.729635 }, {0,0,1}); + AddExhaust (th_att_lin[1], 0.6, 0.078, { 0.817096, -0.488177, 9.729635 }, {0,0,1}); COLOUR4 col_d = {0.9,0.8,1,0}; COLOUR4 col_s = {1.9,0.8,1,0}; COLOUR4 col_a = {0,0,0,0}; COLOUR4 col_white = {1,1,1,0}; - LightEmitter *le = AddPointLight (_V(0,0,-10), 200, 1e-3, 0, 2e-3, col_d, col_s, col_a); + LightEmitter *le = AddPointLight ({0,0,-10}, 200, 1e-3, 0, 2e-3, col_d, col_s, col_a); le->SetIntensityRef (&th_main_level); // ********************* aerodynamics *********************** - hwing = CreateAirfoil3 (LIFT_VERTICAL, _V(0,0,-0.3), VLiftCoeff, 0, 5, 90, 1.5); + hwing = CreateAirfoil3 (LIFT_VERTICAL, {0,0,-0.3}, VLiftCoeff, 0, 5, 90, 1.5); // wing and body lift+drag components - CreateAirfoil3 (LIFT_HORIZONTAL, _V(0,0,-4), HLiftCoeff, 0, 5, 15, 1.5); + CreateAirfoil3 (LIFT_HORIZONTAL, {0,0,-4}, HLiftCoeff, 0, 5, 15, 1.5); // vertical stabiliser and body lift and drag components - CreateControlSurface3 (AIRCTRL_ELEVATOR, 1.4, 1.7, _V( 0,0,-7.2), AIRCTRL_AXIS_XPOS, 1.0, anim_elevator); - CreateControlSurface3 (AIRCTRL_RUDDER, 0.8, 1.7, _V( 0,0,-7.2), AIRCTRL_AXIS_YPOS, 1.0, anim_rudder); - hlaileron = CreateControlSurface3 (AIRCTRL_AILERON, 0.3, 1.7, _V( 7.5,0,-7.2), AIRCTRL_AXIS_XPOS, 1.0, anim_raileron); - hraileron = CreateControlSurface3 (AIRCTRL_AILERON, 0.3, 1.7, _V(-7.5,0,-7.2), AIRCTRL_AXIS_XNEG, 1.0, anim_laileron); - CreateControlSurface3 (AIRCTRL_ELEVATORTRIM, 0.3, 1.7, _V( 0,0,-7.2), AIRCTRL_AXIS_XPOS, 1.0, anim_elevatortrim); + CreateControlSurface3 (AIRCTRL_ELEVATOR, 1.4, 1.7, { 0,0,-7.2}, AIRCTRL_AXIS_XPOS, 1.0, anim_elevator); + CreateControlSurface3 (AIRCTRL_RUDDER, 0.8, 1.7, { 0,0,-7.2}, AIRCTRL_AXIS_YPOS, 1.0, anim_rudder); + hlaileron = CreateControlSurface3 (AIRCTRL_AILERON, 0.3, 1.7, { 7.5,0,-7.2}, AIRCTRL_AXIS_XPOS, 1.0, anim_raileron); + hraileron = CreateControlSurface3 (AIRCTRL_AILERON, 0.3, 1.7, {-7.5,0,-7.2}, AIRCTRL_AXIS_XNEG, 1.0, anim_laileron); + CreateControlSurface3 (AIRCTRL_ELEVATORTRIM, 0.3, 1.7, { 0,0,-7.2}, AIRCTRL_AXIS_XPOS, 1.0, anim_elevatortrim); - CreateVariableDragElement (ssys_gear->GearState().StatePtr(), 0.8, _V(0, -1, 0)); // landing gear - CreateVariableDragElement (ssys_mainretro->RetroCoverState().StatePtr(), 0.2, _V(0,-0.5,6.5)); // retro covers - CreateVariableDragElement (ssys_docking->NconeState().StatePtr(), 3, _V(0, 0, 8)); // nose cone - CreateVariableDragElement (ssys_thermal->RadiatorState().StatePtr(), 1, _V(0,1.5,-4)); // radiator - CreateVariableDragElement (ssys_aerodyn->AirbrakeState().StatePtr(), 4, _V(0,0,-8)); // airbrake + CreateVariableDragElement (ssys_gear->GearState().StatePtr(), 0.8, {0, -1, 0}); // landing gear + CreateVariableDragElement (ssys_mainretro->RetroCoverState().StatePtr(), 0.2, {0,-0.5,6.5}); // retro covers + CreateVariableDragElement (ssys_docking->NconeState().StatePtr(), 3, {0, 0, 8}); // nose cone + CreateVariableDragElement (ssys_thermal->RadiatorState().StatePtr(), 1, {0,1.5,-4}); // radiator + CreateVariableDragElement (ssys_aerodyn->AirbrakeState().StatePtr(), 4, {0,0,-8}); // airbrake - SetRotDrag (_V(0.10,0.13,0.04)); + SetRotDrag ({0.10,0.13,0.04}); // angular damping // ************************* mesh *************************** @@ -1339,7 +1339,7 @@ void DeltaGlider::clbkPostStep (double simt, double simdt, double mjd) bool DeltaGlider::clbkLoadGenericCockpit () { - SetCameraOffset (_V(0,1.467,6.782)); + SetCameraOffset ({0,1.467,6.782}); oapiSetDefNavDisplay (1); oapiSetDefRCSDisplay (1); campos = CAM_GENERIC; @@ -1360,14 +1360,14 @@ bool DeltaGlider::clbkLoadPanel2D (int id, PANELHANDLE hPanel, DWORD viewW, DWOR DefinePanelMain (hPanel); SetPanelScale (hPanel, viewW, viewH); oapiSetPanelNeighbours (-1,-1,1,-1); - SetCameraDefaultDirection (_V(0,0,1)); // forward + SetCameraDefaultDirection ({0,0,1}); // forward oapiCameraSetCockpitDir (0,0); // look forward return true; case 1: DefinePanelOverhead (hPanel); SetPanelScale (hPanel, viewW, viewH); oapiSetPanelNeighbours (-1,-1,-1,0); - SetCameraDefaultDirection (_V(0,0,1)); // forward + SetCameraDefaultDirection ({0,0,1}); // forward oapiCameraSetCockpitDir (0,20*RAD); // look up return true; default: @@ -1454,15 +1454,15 @@ bool DeltaGlider::clbkLoadVC (int id) InitVC (id); - SetCameraDefaultDirection (_V(0,0,1)); // forward + SetCameraDefaultDirection ({0,0,1}); // forward oapiVCRegisterHUD (&huds); // HUD parameters oapiVCRegisterMFD (MFD_LEFT, &mfds_left); // left MFD oapiVCRegisterMFD (MFD_RIGHT, &mfds_right); // right MFD switch (id) { case 0: // pilot - SetCameraOffset (_V(0,1.467,6.782)); - SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); + SetCameraOffset ({0,1.467,6.782}); + SetCameraShiftRange ({0,0,0.1}, {-0.2,0,0}, {0.2,0,0}); oapiVCSetNeighbours (1, 2, -1, -1); // main/retro/hover engine indicators @@ -1480,29 +1480,29 @@ bool DeltaGlider::clbkLoadVC (int id) break; case 1: // front left passenger - SetCameraOffset (_V(-0.7, 1.15, 5.55)); - SetCameraMovement (_V(0.2,-0.05,0.3), -10*RAD, 10*RAD, _V(-0.3,0,0), 80*RAD, 0, _V(0.4,0,0), -90*RAD, 0); + SetCameraOffset ({-0.7, 1.15, 5.55}); + SetCameraMovement ({0.2,-0.05,0.3}, -10*RAD, 10*RAD, {-0.3,0,0}, 80*RAD, 0, {0.4,0,0}, -90*RAD, 0); oapiVCSetNeighbours (-1, 2, 0, 3); campos = CAM_VCPSNGR1; break; case 2: // front right passenger - SetCameraOffset (_V(0.7, 1.15, 5.55)); - SetCameraMovement (_V(-0.2,-0.05,0.3), 10*RAD, 10*RAD, _V(-0.4,0,0), 90*RAD, 0, _V(0.3,0,0), -80*RAD, 0); + SetCameraOffset ({0.7, 1.15, 5.55}); + SetCameraMovement ({-0.2,-0.05,0.3}, 10*RAD, 10*RAD, {-0.4,0,0}, 90*RAD, 0, {0.3,0,0}, -80*RAD, 0); oapiVCSetNeighbours (1, -1, 0, 4); campos = CAM_VCPSNGR2; break; case 3: // rear left passenger - SetCameraOffset (_V(-0.8, 1.2, 4.4)); - SetCameraMovement (_V(0.4,0,0), 0, 0, _V(-0.3,0,0), 70*RAD, 0, _V(0.4,0,0), -90*RAD, 0); + SetCameraOffset ({-0.8, 1.2, 4.4}); + SetCameraMovement ({0.4,0,0}, 0, 0, {-0.3,0,0}, 70*RAD, 0, {0.4,0,0}, -90*RAD, 0); oapiVCSetNeighbours (-1, 4, 1, -1); campos = CAM_VCPSNGR3; break; case 4: // rear right passenger - SetCameraOffset (_V(0.8, 1.2, 4.4)); - SetCameraMovement (_V(-0.4,0,0), 0, 0, _V(-0.4,0,0), 90*RAD, 0, _V(0.3,0,0), -70*RAD, 0); + SetCameraOffset ({0.8, 1.2, 4.4}); + SetCameraMovement ({-0.4,0,0}, 0, 0, {-0.4,0,0}, 90*RAD, 0, {0.3,0,0}, -70*RAD, 0); oapiVCSetNeighbours (3, -1, 2, -1); campos = CAM_VCPSNGR4; break; diff --git a/Src/Vessel/DeltaGlider/DockingSubsys.cpp b/Src/Vessel/DeltaGlider/DockingSubsys.cpp index 3c987ab25..ec80418e8 100644 --- a/Src/Vessel/DeltaGlider/DockingSubsys.cpp +++ b/Src/Vessel/DeltaGlider/DockingSubsys.cpp @@ -94,25 +94,25 @@ NoseconeCtrl::NoseconeCtrl (DockingCtrlSubsystem *_subsys) // Nosecone animation static UINT NConeTLGrp[2] = {GRP_NConeTL1,GRP_NConeTL2}; static MGROUP_ROTATE NConeTL (0, NConeTLGrp, 2, - _V(-0.424,-0.066,9.838), _V(-0.707,-0.707,0), (float)(150*RAD)); + {-0.424,-0.066,9.838}, {-0.707,-0.707,0}, (float)(150*RAD)); static UINT NConeTRGrp[2] = {GRP_NConeTR1,GRP_NConeTR2}; static MGROUP_ROTATE NConeTR (0, NConeTRGrp, 2, - _V( 0.424,-0.066,9.838), _V(-0.707, 0.707,0), (float)(150*RAD)); + { 0.424,-0.066,9.838}, {-0.707, 0.707,0}, (float)(150*RAD)); static UINT NConeBLGrp[2] = {GRP_NConeBL1,GRP_NConeBL2}; static MGROUP_ROTATE NConeBL (0, NConeBLGrp, 2, - _V(-0.424,-0.914,9.838), _V( 0.707,-0.707,0), (float)(150*RAD)); + {-0.424,-0.914,9.838}, { 0.707,-0.707,0}, (float)(150*RAD)); static UINT NConeBRGrp[2] = {GRP_NConeBR1,GRP_NConeBR2}; static MGROUP_ROTATE NConeBR (0, NConeBRGrp, 2, - _V( 0.424,-0.914,9.838), _V( 0.707, 0.707,0), (float)(150*RAD)); + { 0.424,-0.914,9.838}, { 0.707, 0.707,0}, (float)(150*RAD)); static UINT NConeDockGrp[1] = {GRP_NConeDock}; - static MGROUP_TRANSLATE NConeDock (0, NConeDockGrp, 1, _V(0,0,0.06)); + static MGROUP_TRANSLATE NConeDock (0, NConeDockGrp, 1, {0,0,0.06}); // virtual cockpit mesh animation (nose cone visible from cockpit) static UINT VCNConeTLGrp[1] = {GRP_NOSECONE_L_VC}; static MGROUP_ROTATE VCNConeTL (1, VCNConeTLGrp, 1, - _V(-0.424,-0.066,9.838), _V(-0.707,-0.707,0), (float)(150*RAD)); + {-0.424,-0.066,9.838}, {-0.707,-0.707,0}, (float)(150*RAD)); static UINT VCNConeTRGrp[1] = {GRP_NOSECONE_R_VC}; static MGROUP_ROTATE VCNConeTR (1, VCNConeTRGrp, 1, - _V( 0.424,-0.066,9.838), _V(-0.707, 0.707,0), (float)(150*RAD)); + { 0.424,-0.066,9.838}, {-0.707, 0.707,0}, (float)(150*RAD)); anim_nose = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_nose, 0.01, 0.92, &NConeTL); DG()->AddAnimationComponent (anim_nose, 0.01, 0.92, &VCNConeTL); @@ -541,9 +541,9 @@ EscapeLadderCtrl::EscapeLadderCtrl (DockingCtrlSubsystem *_subsys) // Escape ladder animation static UINT LadderGrp[2] = {GRP_Ladder1,GRP_Ladder2}; - static MGROUP_TRANSLATE Ladder1 (0, LadderGrp, 2, _V(0,0,1.1)); + static MGROUP_TRANSLATE Ladder1 (0, LadderGrp, 2, {0,0,1.1}); static MGROUP_ROTATE Ladder2 (0, LadderGrp, 2, - _V(0,-1.05,9.85), _V(1,0,0), (float)(80*RAD)); + {0,-1.05,9.85}, {1,0,0}, (float)(80*RAD)); anim_ladder = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_ladder, 0, 0.5, &Ladder1); DG()->AddAnimationComponent (anim_ladder, 0.5, 1, &Ladder2); diff --git a/Src/Vessel/DeltaGlider/GearSubsys.cpp b/Src/Vessel/DeltaGlider/GearSubsys.cpp index d014b958f..c255c6775 100644 --- a/Src/Vessel/DeltaGlider/GearSubsys.cpp +++ b/Src/Vessel/DeltaGlider/GearSubsys.cpp @@ -66,42 +66,42 @@ GearControl::GearControl (GearSubsystem *_subsys) // Landing gear animation static UINT NWheelStrutGrp[2] = {GRP_NWheelStrut1,GRP_NWheelStrut2}; static MGROUP_ROTATE NWheelStrut (0, NWheelStrutGrp, 2, - _V(0,-1.048,8.561), _V(1,0,0), (float)(-95*RAD)); + {0,-1.048,8.561}, {1,0,0}, (float)(-95*RAD)); static UINT NWheelFCoverGrp[2] = {GRP_NWheelFCover1,GRP_NWheelFCover2}; static MGROUP_ROTATE NWheelFCover (0, NWheelFCoverGrp, 2, - _V(0,-1.145,8.65), _V(1,0,0), (float)(-90*RAD)); + {0,-1.145,8.65}, {1,0,0}, (float)(-90*RAD)); static UINT NWheelLCoverGrp[2] = {GRP_NWheelLCover1,GRP_NWheelLCover2}; static MGROUP_ROTATE NWheelLCover1 (0, NWheelLCoverGrp, 2, - _V(-0.3,-1.222,7.029), _V(0,0.052,0.999), (float)(-90*RAD)); + {-0.3,-1.222,7.029}, {0,0.052,0.999}, (float)(-90*RAD)); static MGROUP_ROTATE NWheelLCover2 (0, NWheelLCoverGrp, 2, - _V(-0.3,-1.222,7.029), _V(0,0.052,0.999), (float)( 90*RAD)); + {-0.3,-1.222,7.029}, {0,0.052,0.999}, (float)( 90*RAD)); static UINT NWheelRCoverGrp[2] = {GRP_NWheelRCover1,GRP_NWheelRCover2}; static MGROUP_ROTATE NWheelRCover1 (0, NWheelRCoverGrp, 2, - _V( 0.3,-1.222,7.029), _V(0,0.052,0.999), (float)( 90*RAD)); + { 0.3,-1.222,7.029}, {0,0.052,0.999}, (float)( 90*RAD)); static MGROUP_ROTATE NWheelRCover2 (0, NWheelRCoverGrp, 2, - _V( 0.3,-1.222,7.029), _V(0,0.052,0.999), (float)(-90*RAD)); + { 0.3,-1.222,7.029}, {0,0.052,0.999}, (float)(-90*RAD)); static UINT LWheelStrutGrp[2] = {GRP_LWheelStrut1,GRP_LWheelStrut2}; static MGROUP_ROTATE LWheelStrut (0, LWheelStrutGrp, 2, - _V(-3.607,-1.137,-3.08), _V(0,0,1), (float)(-90*RAD)); + {-3.607,-1.137,-3.08}, {0,0,1}, (float)(-90*RAD)); static UINT RWheelStrutGrp[2] = {GRP_RWheelStrut1,GRP_RWheelStrut2}; static MGROUP_ROTATE RWheelStrut (0, RWheelStrutGrp, 2, - _V( 3.607,-1.137,-3.08), _V(0,0,1), (float)(90*RAD)); + { 3.607,-1.137,-3.08}, {0,0,1}, (float)(90*RAD)); static UINT LWheelOCoverGrp[4] = {GRP_LWheelOCover1,GRP_LWheelOCover2,GRP_LWheelOCover3,GRP_LWheelOCover4}; static MGROUP_ROTATE LWheelOCover (0, LWheelOCoverGrp, 4, - _V(-3.658,-1.239,-3.038), _V(0,0,1), (float)(-110*RAD)); + {-3.658,-1.239,-3.038}, {0,0,1}, (float)(-110*RAD)); static UINT LWheelICoverGrp[2] = {GRP_LWheelICover1,GRP_LWheelICover2}; static MGROUP_ROTATE LWheelICover1 (0, LWheelICoverGrp, 2, - _V(-2.175,-1.178,-3.438), _V(0,0,1), (float)(90*RAD)); + {-2.175,-1.178,-3.438}, {0,0,1}, (float)(90*RAD)); static MGROUP_ROTATE LWheelICover2 (0, LWheelICoverGrp, 2, - _V(-2.175,-1.178,-3.438), _V(0,0,1), (float)(-90*RAD)); + {-2.175,-1.178,-3.438}, {0,0,1}, (float)(-90*RAD)); static UINT RWheelOCoverGrp[4] = {GRP_RWheelOCover1,GRP_RWheelOCover2,GRP_RWheelOCover3,GRP_RWheelOCover4}; static MGROUP_ROTATE RWheelOCover (0, RWheelOCoverGrp, 4, - _V( 3.658,-1.239,-3.038), _V(0,0,1), (float)( 110*RAD)); + { 3.658,-1.239,-3.038}, {0,0,1}, (float)( 110*RAD)); static UINT RWheelICoverGrp[2] = {GRP_RWheelICover1,GRP_RWheelICover2}; static MGROUP_ROTATE RWheelICover1 (0, RWheelICoverGrp, 2, - _V( 2.175,-1.178,-3.438), _V(0,0,1), (float)(-90*RAD)); + { 2.175,-1.178,-3.438}, {0,0,1}, (float)(-90*RAD)); static MGROUP_ROTATE RWheelICover2 (0, RWheelICoverGrp, 2, - _V( 2.175,-1.178,-3.438), _V(0,0,1), (float)( 90*RAD)); + { 2.175,-1.178,-3.438}, {0,0,1}, (float)( 90*RAD)); anim_gear = DG()->CreateAnimation (1); DG()->AddAnimationComponent (anim_gear, 0.3, 1, &NWheelStrut); DG()->AddAnimationComponent (anim_gear, 0.3, 0.9, &NWheelFCover); diff --git a/Src/Vessel/DeltaGlider/HoverSubsys.cpp b/Src/Vessel/DeltaGlider/HoverSubsys.cpp index 77cb577f0..6a3ae62c2 100644 --- a/Src/Vessel/DeltaGlider/HoverSubsys.cpp +++ b/Src/Vessel/DeltaGlider/HoverSubsys.cpp @@ -564,7 +564,7 @@ HoverManualComponent::HoverManualComponent (HoverSubsystem *_subsys) // Hover throttle VC animation static UINT HoverThrottleGrp[2] = {GRP_THROTTLE_HOVER_1_VC,GRP_THROTTLE_HOVER_2_VC}; static MGROUP_ROTATE HoverThrottle (1, HoverThrottleGrp, 2, - _V(-0.41,0.85,6.9226), _V(1,0,0), (float)(50*RAD)); + {-0.41,0.85,6.9226}, {1,0,0}, (float)(50*RAD)); anim_hoverthrottle = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_hoverthrottle, 0, 1, &HoverThrottle); @@ -591,7 +591,7 @@ bool HoverManualComponent::clbkLoadVC (int vcid) // Hover throttle oapiVCRegisterArea (ELID_THROTTLE, PANEL_REDRAW_ALWAYS, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED); - oapiVCSetAreaClickmode_Quadrilateral (ELID_THROTTLE, _V(-0.44,0.87,6.81), _V(-0.35,0.87,6.81), _V(-0.44,0.95,6.91), _V(-0.35,0.95,6.91)); + oapiVCSetAreaClickmode_Quadrilateral (ELID_THROTTLE, {-0.44,0.87,6.81}, {-0.35,0.87,6.81}, {-0.44,0.95,6.91}, {-0.35,0.95,6.91}); return true; } diff --git a/Src/Vessel/DeltaGlider/HudCtrl.cpp b/Src/Vessel/DeltaGlider/HudCtrl.cpp index 7d34c2400..e3f6ddfe5 100644 --- a/Src/Vessel/DeltaGlider/HudCtrl.cpp +++ b/Src/Vessel/DeltaGlider/HudCtrl.cpp @@ -43,9 +43,9 @@ HUDControl::HUDControl (DeltaGlider *vessel) static UINT HudGrp1[2] = {GRP_HUD_FRAME_VC, GRP_HUD_PANE_VC}; static UINT HudGrp2[3] = {GRP_HUD_FRAME_VC, GRP_HUD_PANE_VC, GRP_HUD_RAIL_VC}; static MGROUP_ROTATE HudTransform1 (1, HudGrp1, 2, - _V(0,1.5836,7.1280), _V(1,0,0), (float)(-62*RAD)); + {0,1.5836,7.1280}, {1,0,0}, (float)(-62*RAD)); static MGROUP_ROTATE HudTransform2 (1, HudGrp2, 3, - _V(0,0.99,6.53), _V(1,0,0), (float)(-26*RAD)); + {0,0.99,6.53}, {1,0,0}, (float)(-26*RAD)); anim_vc_hud = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_vc_hud, 0, 0.4, &HudTransform1); DG()->AddAnimationComponent (anim_vc_hud, 0.4, 1, &HudTransform2); diff --git a/Src/Vessel/DeltaGlider/LightSubsys.cpp b/Src/Vessel/DeltaGlider/LightSubsys.cpp index 24b098c02..30f0b38af 100644 --- a/Src/Vessel/DeltaGlider/LightSubsys.cpp +++ b/Src/Vessel/DeltaGlider/LightSubsys.cpp @@ -242,7 +242,7 @@ void CockpitLight::SetLight (int mode, bool force) static const COLOUR4 wcol = {1.0f,1.0f,1.0f,0.0f}; static const COLOUR4 rcol = {0.6f,0.05f,0.0f,0.0f}; COLOUR4 col = (mode == 1 ? wcol : rcol); - light = (PointLight*)DG()->AddPointLight(_V(0,1.65,6.68), 3, 0, 0, 3, col, col, zero); + light = (PointLight*)DG()->AddPointLight({0,1.65,6.68}, 3, 0, 0, 3, col, col, zero); light->SetVisibility (LightEmitter::VIS_COCKPIT); light->Activate(true); double intens = (float)(0.2 + brightness*0.8); @@ -387,10 +387,10 @@ void LandDockLight::SetLight (int mode, bool force) COLOUR4 col_a = {0,0,0,0}; COLOUR4 col_white = {1,1,1,0}; if (mode == 1) { - light = (SpotLight*)DG()->AddSpotLight(_V(0.3,0.3,8.5), _V(0,0,1), 150, 1e-3, 0, 1e-3, RAD*30, RAD*60, col_white, col_white, col_a); + light = (SpotLight*)DG()->AddSpotLight({0.3,0.3,8.5}, {0,0,1}, 150, 1e-3, 0, 1e-3, RAD*30, RAD*60, col_white, col_white, col_a); } else { double tilt = -10.0*RAD; - light = (SpotLight*)DG()->AddSpotLight(_V(0.1,-0.3,7.5), _V(0,sin(tilt),cos(tilt)), 5000, 1e-3, 1e-5, 2e-7, RAD*25, RAD*40, col_white, col_white, col_a); + light = (SpotLight*)DG()->AddSpotLight({0.1,-0.3,7.5}, {0,sin(tilt),cos(tilt)}, 5000, 1e-3, 1e-5, 2e-7, RAD*25, RAD*40, col_white, col_white, col_a); } light->SetVisibility (LightEmitter::VIS_ALWAYS); } diff --git a/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp b/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp index d84467106..c967c7d45 100644 --- a/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp +++ b/Src/Vessel/DeltaGlider/MainRetroSubsys.cpp @@ -97,14 +97,14 @@ MainRetroThrottle::MainRetroThrottle (MainRetroSubsystem *_subsys) // VC animation: Left main engine throttle static UINT MainThrottleLGrp[2] = {GRP_THROTTLE_MAIN_L1_VC,GRP_THROTTLE_MAIN_L2_VC}; static MGROUP_ROTATE MainThrottleL (1, MainThrottleLGrp, 2, - _V(0,0.72,6.9856), _V(1,0,0), (float)(50*RAD)); + {0,0.72,6.9856}, {1,0,0}, (float)(50*RAD)); anim_lever[0] = DG()->CreateAnimation (0.4); DG()->AddAnimationComponent (anim_lever[0], 0, 1, &MainThrottleL); // VC animation: Right main engine throttle static UINT MainThrottleRGrp[2] = {GRP_THROTTLE_MAIN_R1_VC,GRP_THROTTLE_MAIN_R2_VC}; static MGROUP_ROTATE MainThrottleR (1, MainThrottleRGrp, 2, - _V(0,0.72,6.9856), _V(1,0,0), (float)(50*RAD)); + {0,0.72,6.9856}, {1,0,0}, (float)(50*RAD)); anim_lever[1] = DG()->CreateAnimation (0.4); DG()->AddAnimationComponent (anim_lever[1], 0, 1, &MainThrottleR); } @@ -129,7 +129,7 @@ bool MainRetroThrottle::clbkLoadVC (int vcid) // Throttle lever animations oapiVCRegisterArea (ELID_LEVERS, PANEL_REDRAW_ALWAYS, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED); - oapiVCSetAreaClickmode_Quadrilateral (ELID_LEVERS, _V(-0.372,0.918,6.905), _V(-0.279,0.918,6.905), _V(-0.372,0.885,7.11), _V(-0.279,0.885,7.11)); + oapiVCSetAreaClickmode_Quadrilateral (ELID_LEVERS, {-0.372,0.918,6.905}, {-0.279,0.918,6.905}, {-0.372,0.885,7.11}, {-0.279,0.885,7.11}); return true; } @@ -975,16 +975,16 @@ RetroCoverControl::RetroCoverControl (MainRetroSubsystem *_subsys) // Retro cover animation static UINT RCoverTLGrp[2] = {GRP_RCoverTL1,GRP_RCoverTL2}; static MGROUP_ROTATE RCoverTL (0, RCoverTLGrp, 2, - _V(-2.156,-0.49,6.886), _V(-0.423,0.23,-0.877), (float)( 70*RAD)); + {-2.156,-0.49,6.886}, {-0.423,0.23,-0.877}, (float)( 70*RAD)); static UINT RCoverBLGrp[2] = {GRP_RCoverBL1,GRP_RCoverBL2}; static MGROUP_ROTATE RCoverBL (0, RCoverBLGrp, 2, - _V(-2.156,-0.49,6.886), _V(-0.434,-0.037,-0.9), (float)(-70*RAD)); + {-2.156,-0.49,6.886}, {-0.434,-0.037,-0.9}, (float)(-70*RAD)); static UINT RCoverTRGrp[2] = {GRP_RCoverTR1,GRP_RCoverTR2}; static MGROUP_ROTATE RCoverTR (0, RCoverTRGrp, 2, - _V( 2.156,-0.49,6.886), _V( 0.423,0.23,-0.877), (float)(-70*RAD)); + { 2.156,-0.49,6.886}, { 0.423,0.23,-0.877}, (float)(-70*RAD)); static UINT RCoverBRGrp[2] = {GRP_RCoverBR1,GRP_RCoverBR2}; static MGROUP_ROTATE RCoverBR (0, RCoverBRGrp, 2, - _V( 2.156,-0.49,6.886), _V( 0.434,-0.037,-0.9), (float)( 70*RAD)); + { 2.156,-0.49,6.886}, { 0.434,-0.037,-0.9}, (float)( 70*RAD)); anim_rcover = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_rcover, 0, 1, &RCoverTL); DG()->AddAnimationComponent (anim_rcover, 0, 1, &RCoverBL); diff --git a/Src/Vessel/DeltaGlider/MfdSubsys.cpp b/Src/Vessel/DeltaGlider/MfdSubsys.cpp index 4cebbaf21..663df369e 100644 --- a/Src/Vessel/DeltaGlider/MfdSubsys.cpp +++ b/Src/Vessel/DeltaGlider/MfdSubsys.cpp @@ -121,13 +121,13 @@ bool MfdSubsystem::clbkLoadVC (int vcid) const double xofs = (mfdid == MFD_LEFT ? -0.2684 : 0.0616); oapiVCRegisterArea (ELID_BTNROW, PANEL_REDRAW_MOUSE, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNROW, _V(0.0840+xofs, 1.0745, 7.2238), _V(0.1228+xofs, 1.0745, 7.2238), _V(0.0840+xofs, 1.0587, 7.2180), _V(0.1228+xofs, 1.0587, 7.2180)); + oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNROW, {0.0840+xofs, 1.0745, 7.2238}, {0.1228+xofs, 1.0745, 7.2238}, {0.0840+xofs, 1.0587, 7.2180}, {0.1228+xofs, 1.0587, 7.2180}); oapiVCRegisterArea (ELID_BTNCOL[0], PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNCOL[0], _V(0+xofs, 1.2155, 7.2751), _V(0.0168+xofs, 1.2155, 7.2751), _V(0+xofs, 1.0963, 7.2317), _V(0.0168+xofs, 1.0963, 7.2317)); + oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNCOL[0], {0+xofs, 1.2155, 7.2751}, {0.0168+xofs, 1.2155, 7.2751}, {0+xofs, 1.0963, 7.2317}, {0.0168+xofs, 1.0963, 7.2317}); oapiVCRegisterArea (ELID_BTNCOL[1], PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); - oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNCOL[1], _V(0.1900+xofs, 1.2155, 7.2751), _V(0.2068+xofs, 1.2155, 7.2751), _V(0.1900+xofs, 1.0963, 7.2317), _V(0.2068+xofs, 1.0963, 7.2317)); + oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNCOL[1], {0.1900+xofs, 1.2155, 7.2751}, {0.2068+xofs, 1.2155, 7.2751}, {0.1900+xofs, 1.0963, 7.2317}, {0.2068+xofs, 1.0963, 7.2317}); return true; } diff --git a/Src/Vessel/DeltaGlider/PressureSubsys.cpp b/Src/Vessel/DeltaGlider/PressureSubsys.cpp index 15fd95934..75cefe37e 100644 --- a/Src/Vessel/DeltaGlider/PressureSubsys.cpp +++ b/Src/Vessel/DeltaGlider/PressureSubsys.cpp @@ -288,10 +288,10 @@ AirlockCtrl::AirlockCtrl (PressureSubsystem *_subsys) // Outer airlock animation static UINT OLockGrp[2] = {GRP_OLock1,GRP_OLock2}; static MGROUP_ROTATE OLock (0, OLockGrp, 2, - _V(0,-0.080,9.851), _V(1,0,0), (float)(110*RAD)); + {0,-0.080,9.851}, {1,0,0}, (float)(110*RAD)); static UINT VCOLockGrp[1] = {13}; static MGROUP_ROTATE VCOLock (1, VCOLockGrp, 1, - _V(0,-0.080,9.851), _V(1,0,0), (float)(110*RAD)); + {0,-0.080,9.851}, {1,0,0}, (float)(110*RAD)); anim_olock = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_olock, 0, 1, &OLock); DG()->AddAnimationComponent (anim_olock, 0, 1, &VCOLock); @@ -299,11 +299,11 @@ AirlockCtrl::AirlockCtrl (PressureSubsystem *_subsys) // Inner airlock animation static UINT ILockGrp[2] = {GRP_ILock1,GRP_ILock2}; static MGROUP_ROTATE ILock (0, ILockGrp, 2, - _V(0,-0.573,7.800), _V(1,0,0), (float)(85*RAD)); + {0,-0.573,7.800}, {1,0,0}, (float)(85*RAD)); // virtual cockpit mesh animation (inner airlock visible from cockpit) static UINT VCILockGrp[4] = {GRP_ILOCK1_VC,GRP_ILOCK2_VC,GRP_ILOCK3_VC,GRP_ILOCK_GLASS_VC}; static MGROUP_ROTATE VCILock (1, VCILockGrp, 4, - _V(0,-0.573,7.800), _V(1,0,0), (float)(85*RAD)); + {0,-0.573,7.800}, {1,0,0}, (float)(85*RAD)); anim_ilock = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_ilock, 0, 1, &ILock); DG()->AddAnimationComponent (anim_ilock, 0, 1, &VCILock); @@ -609,22 +609,22 @@ TophatchCtrl::TophatchCtrl (PressureSubsystem *_subsys) // Top hatch animation static UINT HatchGrp[2] = {GRP_Hatch1,GRP_Hatch2}; static MGROUP_ROTATE Hatch (0, HatchGrp, 2, - _V(0,2.069,5.038), _V(1,0,0), (float)(110*RAD)); + {0,2.069,5.038}, {1,0,0}, (float)(110*RAD)); static UINT VCHatchGrp[1] = {GRP_HATCH_VC}; static MGROUP_ROTATE VCHatch (1, VCHatchGrp, 1, - _V(0,2.069,5.038), _V(1,0,0), (float)(110*RAD)); + {0,2.069,5.038}, {1,0,0}, (float)(110*RAD)); static UINT RearLadderGrp[2] = {GRP_RearLadder1,GRP_RearLadder2}; static MGROUP_ROTATE RearLadder1 (0, RearLadderGrp, 2, - _V(0,1.7621,4.0959), _V(1,0,0), (float)(-20*RAD)); + {0,1.7621,4.0959}, {1,0,0}, (float)(-20*RAD)); static MGROUP_ROTATE RearLadder2 (0, RearLadderGrp+1, 1, - _V(0,1.1173,4.1894), _V(1,0,0), (float)(180*RAD)); + {0,1.1173,4.1894}, {1,0,0}, (float)(180*RAD)); // virtual cockpit ladder animation static UINT VCRearLadderGrp[2] = {GRP_LADDER1_VC,GRP_LADDER2_VC}; static MGROUP_ROTATE VCRearLadder1 (1, VCRearLadderGrp, 2, - _V(0,1.7621,4.0959), _V(1,0,0), (float)(-20*RAD)); + {0,1.7621,4.0959}, {1,0,0}, (float)(-20*RAD)); static MGROUP_ROTATE VCRearLadder2 (1, VCRearLadderGrp+1, 1, - _V(0,1.1173,4.1894), _V(1,0,0), (float)(180*RAD)); + {0,1.1173,4.1894}, {1,0,0}, (float)(180*RAD)); anim_hatch = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_hatch, 0, 1, &Hatch); DG()->AddAnimationComponent (anim_hatch, 0, 1, &VCHatch); diff --git a/Src/Vessel/DeltaGlider/ScramSubsys.cpp b/Src/Vessel/DeltaGlider/ScramSubsys.cpp index 56de95e58..6fd0e0cd5 100644 --- a/Src/Vessel/DeltaGlider/ScramSubsys.cpp +++ b/Src/Vessel/DeltaGlider/ScramSubsys.cpp @@ -157,10 +157,10 @@ ScramSubsystem::ScramSubsystem (DeltaGlider *dg) PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1 }; for (int i = 0; i < 2; i++) { - hScram[i] = dg->CreateThruster (_V(i?0.9:-0.9, -0.8, -5.6), dir, 0, hProp, 0); + hScram[i] = dg->CreateThruster ({i?0.9:-0.9, -0.8, -5.6}, dir, 0, hProp, 0); scram->AddThrusterDefinition (hScram[i], SCRAM_FHV[modelidx], SCRAM_INTAKE_AREA, SCRAM_TEMAX[modelidx], SCRAM_MAX_DMF[modelidx]); - ph = DG()->AddExhaustStream (hScram[0], _V(i?1:-1,-1.1,-5.4), &exhaust_scram); + ph = DG()->AddExhaustStream(hScram[0], {i ? 1.0 : -1.0, -1.1, -5.4}, &exhaust_scram); if (ph) oapiParticleSetLevelRef (ph, scram_intensity+i); scram_max[i] = scram_intensity[i] = 0.0; } @@ -260,14 +260,14 @@ ScramThrottle::ScramThrottle (DGSubsystem *_subsys) // VC animation: Left scram engine throttle static UINT ScramThrottleLGrp[2] = {GRP_THROTTLE_SCRAM_L1_VC,GRP_THROTTLE_SCRAM_L2_VC}; static MGROUP_ROTATE ScramThrottleL (1, ScramThrottleLGrp, 2, - _V(0,0.7849,6.96), _V(1,0,0), (float)(30*RAD)); + {0,0.7849,6.96}, {1,0,0}, (float)(30*RAD)); anim_lever[0] = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_lever[0], 0, 1, &ScramThrottleL); // VC animation: Right scram engine throttle static UINT ScramThrottleRGrp[2] = {GRP_THROTTLE_SCRAM_R1_VC,GRP_THROTTLE_SCRAM_R2_VC}; static MGROUP_ROTATE ScramThrottleR (1, ScramThrottleRGrp, 2, - _V(0,0.7849,6.96), _V(1,0,0), (float)(30*RAD)); + {0,0.7849,6.96}, {1,0,0}, (float)(30*RAD)); anim_lever[1] = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_lever[1], 0, 1, &ScramThrottleR); } @@ -292,7 +292,7 @@ bool ScramThrottle::clbkLoadVC (int vcid) // Throttle lever animations oapiVCRegisterArea (ELID_LEVER, PANEL_REDRAW_ALWAYS, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED); - oapiVCSetAreaClickmode_Quadrilateral (ELID_LEVER, _V(-0.45,0.98,6.94), _V(-0.39,0.98,6.94), _V(-0.45,0.95,7.07), _V(-0.39,0.95,7.07)); + oapiVCSetAreaClickmode_Quadrilateral (ELID_LEVER, {-0.45,0.98,6.94}, {-0.39,0.98,6.94}, {-0.45,0.95,7.07}, {-0.39,0.95,7.07}); return true; } diff --git a/Src/Vessel/DeltaGlider/ThermalSubsys.cpp b/Src/Vessel/DeltaGlider/ThermalSubsys.cpp index b081dc160..1cf831ef1 100644 --- a/Src/Vessel/DeltaGlider/ThermalSubsys.cpp +++ b/Src/Vessel/DeltaGlider/ThermalSubsys.cpp @@ -233,14 +233,14 @@ double ThermalSubsystem::SolarRadiation(VECTOR3 *sdir) VECTOR3 Ppos, Vpos; double vdist, pdist, prad, srad; DG()->GetGlobalPos(Vpos); - vdist = length(Vpos); // distance from sun + vdist = len(Vpos); // distance from sun OBJHANDLE hObj = DG()->GetSurfaceRef(); while (hObj && oapiGetObjectType(hObj) == OBJTP_PLANET) { prad = oapiGetSize(hObj); oapiGetGlobalPos(hObj, &Ppos); - pdist = length(Ppos); + pdist = len(Ppos); if (vdist > pdist) { - double d = length(crossp(Ppos, Ppos-Vpos))/vdist; + double d = len(cross(Ppos, Ppos - Vpos)) / vdist; if (d < prad) return 0.0; } hObj = oapiGetGbodyParent(hObj); @@ -267,7 +267,7 @@ double ThermalSubsystem::PlanetRadiation(VECTOR3 *pdir) double prad = oapiGetSize(hObj); oapiGetGlobalPos(hObj, &Ppos); DG()->GetGlobalPos(Vpos); - double pdist = length(Ppos-Vpos); + double pdist = len(Ppos-Vpos); if (pdir) *pdir = (Ppos-Vpos)/pdist; double alt_ratio = prad/pdist; const double Hplanet = 237.0; // W/m^2; only true for Earth @@ -293,8 +293,8 @@ void ThermalSubsystem::AddAlbedoReflection (double rPower, const VECTOR3 &dir, d OBJHANDLE hObj = DG()->GetSurfaceRef(); oapiGetGlobalPos(hObj, &Ppos); DG()->GetGlobalPos(Vpos); - double cosphi = dotp(unit(Vpos-Ppos), unit(-Ppos)); - double irelalt = oapiGetSize(hObj)/length(Vpos-Ppos); + double cosphi = dot(unit(Vpos - Ppos), unit(-Ppos)); + double irelalt = oapiGetSize(hObj) / len(Vpos - Ppos); rPower *= albedo * irelalt*irelalt * cosphi; AddIrradiance (rPower, dir, compartmentQ); } @@ -353,8 +353,8 @@ void ThermalSubsystem::AddRadiatorIrradiance (double rPower, const VECTOR3 &dir, // panel 1 pprog = min(1.0, rstate/0.33); alpha = (pprog*175.0-100.0)*RAD; - paneldir = _V(0, sin(alpha), -cos(alpha)); - cosa = dotp(dir, paneldir); // irradiance cosine + paneldir = {0, sin(alpha), -cos(alpha)}; + cosa = dot(dir, paneldir); // irradiance cosine if (cosa > 0.0) { if (pprog < 0.5) cosa *= pprog*2.0; cs = cosa * A_radiatorpanel2; @@ -365,8 +365,8 @@ void ThermalSubsystem::AddRadiatorIrradiance (double rPower, const VECTOR3 &dir, // panel 2 pprog = max (0.0, min(1.0, (rstate-0.5)*4.0)); alpha = pprog*145.0*RAD; - paneldir = _V(-sin(alpha), -cos(alpha), 0); - cosa = dotp(dir, paneldir); + paneldir = {-sin(alpha), -cos(alpha), 0}; + cosa = dot(dir, paneldir); if (cosa > 0.0) { if (pprog < 0.5) cosa *= pprog*2.0; cs = cosa * A_radiatorpanel1; @@ -377,8 +377,8 @@ void ThermalSubsystem::AddRadiatorIrradiance (double rPower, const VECTOR3 &dir, // panel 3 pprog = max (0.0, min(1.0, (rstate-0.75)*4.0)); alpha = pprog*145.0*RAD; - paneldir = _V(sin(alpha), -cos(alpha), 0); - cosa = dotp(dir, paneldir); + paneldir = {sin(alpha), -cos(alpha), 0}; + cosa = dot(dir, paneldir); if (cosa > 0.0) { if (pprog < 0.5) cosa *= pprog*2.0; cs = cosa * A_radiatorpanel1; @@ -1009,34 +1009,34 @@ RadiatorControl::RadiatorControl (ThermalSubsystem *_subsys) // Radiator animation static UINT RaddoorGrp[3] = {GRP_Raddoor1,GRP_Raddoor2,GRP_Radiator4}; static MGROUP_ROTATE Raddoor (0, RaddoorGrp, 3, - _V(0,1.481,-3.986), _V(1,0,0), (float)(175*RAD)); + {0,1.481,-3.986}, {1,0,0}, (float)(175*RAD)); static UINT FRadiatorGrp[1] = {GRP_Radiator4}; static MGROUP_ROTATE FRadiator (0, FRadiatorGrp, 1, - _V(0,1.91,-2.965), _V(1,0,0), (float)(185*RAD)); + {0,1.91,-2.965}, {1,0,0}, (float)(185*RAD)); static UINT RadiatorGrp[7] = {GRP_Radiator1,GRP_Radiator1a,GRP_Radiator1b, GRP_Radiator2,GRP_Radiator2a,GRP_Radiator2b,GRP_Radiator3}; static MGROUP_TRANSLATE Radiator (0, RadiatorGrp, 7, - _V(0,0.584,-0.157)); + {0,0.584,-0.157}); static UINT LRadiatorGrp[3] = {GRP_Radiator1,GRP_Radiator1a,GRP_Radiator1b}; static MGROUP_ROTATE LRadiator (0, LRadiatorGrp, 3, - _V(-0.88,1.94,-4.211), _V(0,0.260,0.966), (float)(145*RAD)); + {-0.88,1.94,-4.211}, {0,0.260,0.966}, (float)(145*RAD)); static UINT RRadiatorGrp[3] = {GRP_Radiator2,GRP_Radiator2a,GRP_Radiator2b}; static MGROUP_ROTATE RRadiator (0, RRadiatorGrp, 3, - _V(0.93,1.91,-4.211), _V(0,0.260,0.966), (float)(-145*RAD)); + {0.93,1.91,-4.211}, {0,0.260,0.966}, (float)(-145*RAD)); static VECTOR3 axis1 = {cos(145*RAD),sin(145*RAD)*cos(0.26292),sin(145*RAD)*sin(-0.26292)}; static UINT LaRadiatorGrp[1] = {GRP_Radiator1a}; static MGROUP_ROTATE LaRadiator (0, LaRadiatorGrp, 1, - _V(-0.91, 1.86, -5.055), axis1, (float)(180*RAD)); + {-0.91, 1.86, -5.055}, axis1, (float)(180*RAD)); static UINT LbRadiatorGrp[1] = {GRP_Radiator1b}; static MGROUP_ROTATE LbRadiator (0, LbRadiatorGrp, 1, - _V(-0.91, 2.075, -4.315), axis1, (float)(-180*RAD)); + {-0.91, 2.075, -4.315}, axis1, (float)(-180*RAD)); static VECTOR3 axis2 = {cos(-145*RAD),sin(-145*RAD)*cos(0.26292),sin(-145*RAD)*sin(-0.26292)}; static UINT RaRadiatorGrp[1] = {GRP_Radiator2a}; static MGROUP_ROTATE RaRadiator (0, RaRadiatorGrp, 1, - _V(0.91, 1.675, -5.01), axis2, (float)(180*RAD)); + {0.91, 1.675, -5.01}, axis2, (float)(180*RAD)); static UINT RbRadiatorGrp[1] = {GRP_Radiator2b}; static MGROUP_ROTATE RbRadiator (0, RbRadiatorGrp, 1, - _V(0.91, 1.89, -4.27), axis2, (float)(-180*RAD)); + {0.91, 1.89, -4.27}, axis2, (float)(-180*RAD)); anim_radiator = DG()->CreateAnimation (0); DG()->AddAnimationComponent (anim_radiator, 0, 0.25, &Raddoor); DG()->AddAnimationComponent (anim_radiator, 0.28, 0.53, &FRadiator); diff --git a/Src/Vessel/Dragonfly/Dragonfly.cpp b/Src/Vessel/Dragonfly/Dragonfly.cpp index 3f599c8c4..ad1104e85 100644 --- a/Src/Vessel/Dragonfly/Dragonfly.cpp +++ b/Src/Vessel/Dragonfly/Dragonfly.cpp @@ -151,9 +151,9 @@ void Dragonfly::SetClassCaps (FILEHANDLE cfg) SetSize (4.0); SetEmptyMass (EMPTY_MASS); - SetCrossSections (_V(23.7,22.5,17.3)); - SetPMI (_V(5.4,5.4,2.5)); - SetCameraOffset (_V(0,1.5,0)); + SetCrossSections ({23.7,22.5,17.3}); + SetPMI ({5.4,5.4,2.5}); + SetCameraOffset ({0,1.5,0}); // ************************* propellant specs ********************************** @@ -162,33 +162,33 @@ void Dragonfly::SetClassCaps (FILEHANDLE cfg) // *********************** thruster definitions ******************************** // thrusters in left pod - th_lp[0] = CreateThruster (_V(-3.5,0,0), _V(1,0,0), 2*MAX_RCS_THRUST, ph_main, ISP); - th_lp[1] = CreateThruster (_V(-2.98,0,-0.8), _V(0,0,1), MAX_RCS_THRUST, ph_main, ISP); - th_lp[2] = CreateThruster (_V(-2.98,0,0.8), _V(0,0,-1), MAX_RCS_THRUST, ph_main, ISP); - th_lp[3] = CreateThruster (_V(-2.98,-0.8,0), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP); - th_lp[4] = CreateThruster (_V(-2.98,0.8,0), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP); + th_lp[0] = CreateThruster ({-3.5,0,0}, {1,0,0}, 2*MAX_RCS_THRUST, ph_main, ISP); + th_lp[1] = CreateThruster ({-2.98,0,-0.8}, {0,0,1}, MAX_RCS_THRUST, ph_main, ISP); + th_lp[2] = CreateThruster ({-2.98,0,0.8}, {0,0,-1}, MAX_RCS_THRUST, ph_main, ISP); + th_lp[3] = CreateThruster ({-2.98,-0.8,0}, {0,1,0}, MAX_RCS_THRUST, ph_main, ISP); + th_lp[4] = CreateThruster ({-2.98,0.8,0}, {0,-1,0}, MAX_RCS_THRUST, ph_main, ISP); // thrusters in right pod - th_rp[0] = CreateThruster (_V(3.5,0,0), _V(-1,0,0), 2*MAX_RCS_THRUST, ph_main, ISP); - th_rp[1] = CreateThruster (_V(2.98,0,-0.8), _V(0,0,1), MAX_RCS_THRUST, ph_main, ISP); - th_rp[2] = CreateThruster (_V(2.98,0,0.8), _V(0,0,-1), MAX_RCS_THRUST, ph_main, ISP); - th_rp[3] = CreateThruster (_V(2.98,-0.8,0), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP); - th_rp[4] = CreateThruster (_V(2.98,0.8,0), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP); + th_rp[0] = CreateThruster ({3.5,0,0}, {-1,0,0}, 2*MAX_RCS_THRUST, ph_main, ISP); + th_rp[1] = CreateThruster ({2.98,0,-0.8}, {0,0,1}, MAX_RCS_THRUST, ph_main, ISP); + th_rp[2] = CreateThruster ({2.98,0,0.8}, {0,0,-1}, MAX_RCS_THRUST, ph_main, ISP); + th_rp[3] = CreateThruster ({2.98,-0.8,0}, {0,1,0}, MAX_RCS_THRUST, ph_main, ISP); + th_rp[4] = CreateThruster ({2.98,0.8,0}, {0,-1,0}, MAX_RCS_THRUST, ph_main, ISP); // thrusters in aft pod (rotational RCS) - th_ap[0] = CreateThruster (_V(-0.8,0,-11.1), _V(1,0,0), MAX_RCS_THRUST, ph_main, ISP); - th_ap[1] = CreateThruster (_V(0.8,0,-11.1), _V(-1,0,0), MAX_RCS_THRUST, ph_main, ISP); - th_ap[2] = CreateThruster (_V(0,-0.8,-11.1), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP); - th_ap[3] = CreateThruster (_V(0,0.8,-11.1), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP); + th_ap[0] = CreateThruster ({-0.8,0,-11.1}, {1,0,0}, MAX_RCS_THRUST, ph_main, ISP); + th_ap[1] = CreateThruster ({0.8,0,-11.1}, {-1,0,0}, MAX_RCS_THRUST, ph_main, ISP); + th_ap[2] = CreateThruster ({0,-0.8,-11.1}, {0,1,0}, MAX_RCS_THRUST, ph_main, ISP); + th_ap[3] = CreateThruster ({0,0.8,-11.1}, {0,-1,0}, MAX_RCS_THRUST, ph_main, ISP); // exhaust definitions for left pod - AddExhaust (th_lp[0], 1, 0.15, _V(-3.5,0.18,-0.18), _V(-1,0,0)); - AddExhaust (th_lp[0], 1, 0.15, _V(-3.5,-0.18,0.18), _V(-1,0,0)); + AddExhaust (th_lp[0], 1, 0.15, {-3.5,0.18,-0.18}, {-1,0,0}); + AddExhaust (th_lp[0], 1, 0.15, {-3.5,-0.18,0.18}, {-1,0,0}); for (i = 1; i < 5; i++) AddExhaust (th_lp[i], 1, 0.15); // exhaust definitions for right pod - AddExhaust (th_rp[0], 1, 0.15, _V(3.5,-0.18,-0.18), _V(1,0,0)); - AddExhaust (th_rp[0], 1, 0.15, _V(3.5,0.18,0.18), _V(1,0,0)); + AddExhaust (th_rp[0], 1, 0.15, {3.5,-0.18,-0.18}, {1,0,0}); + AddExhaust (th_rp[0], 1, 0.15, {3.5,0.18,0.18}, {1,0,0}); for (i = 1; i < 5; i++) AddExhaust (th_rp[i], 1, 0.15); // exhaust definitions for aft pod @@ -199,7 +199,7 @@ void Dragonfly::SetClassCaps (FILEHANDLE cfg) // *************************** docking port ************************************ - SetDockParams (_V(0,0,3.2), _V(0,0,1), _V(0,1,0)); + SetDockParams ({0,0,3.2}, {0,0,1}, {0,1,0}); // ******************************** mesh *************************************** @@ -228,12 +228,12 @@ void Dragonfly::LoadState (FILEHANDLE scn, void *vs) SetAnimState (anim_UY_ant, UY_pos); float ang=(150-UY_pos*300.0)/180.0*acos(-1.0); - Upper_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); + Upper_ant_pitch.trans.P.rotparam.axis={cos(ang),0,-sin(ang)}; SetAnimState (anim_UP_ant, UP_pos); SetAnimState (anim_LY_ant, LY_pos); ang=(150-LY_pos*300.0)/180.0*acos(-1.0); - Lower_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); + Lower_ant_pitch.trans.P.rotparam.axis={cos(ang),0,-sin(ang)}; SetAnimState (anim_LP_ant, LP_pos); SetAnimState (anim_latch, dock_latched); @@ -551,7 +551,7 @@ void Dragonfly::Timestep (double simt) if (UY_pos>1) UY_pos=1; SetAnimState (anim_UY_ant, UY_pos); float ang=(150-UY_pos*300.0)/180.0*acos(-1.0); - Upper_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); + Upper_ant_pitch.trans.P.rotparam.axis={cos(ang),0,-sin(ang)}; }; if ((*AC_power>0)&&(UP_handle)) {if ((UP_handle<0)&&(UP_pos>0)) UP_pos-=oapiGetSysStep()/18.0; @@ -567,7 +567,7 @@ void Dragonfly::Timestep (double simt) if (LY_pos>1) LY_pos=1; SetAnimState (anim_LY_ant, LY_pos); float ang=(150-LY_pos*300.0)/180.0*acos(-1.0); - Lower_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); + Lower_ant_pitch.trans.P.rotparam.axis={cos(ang),0,-sin(ang)}; }; if ((*AC_power>0)&&(LP_handle)) {if ((LP_handle<0)&&(LP_pos>0)) LP_pos-=oapiGetSysStep()/18.0; diff --git a/Src/Vessel/Dragonfly/Hsystems.cpp b/Src/Vessel/Dragonfly/Hsystems.cpp index 104fedfec..ef2e2146d 100644 --- a/Src/Vessel/Dragonfly/Hsystems.cpp +++ b/Src/Vessel/Dragonfly/Hsystems.cpp @@ -416,7 +416,7 @@ VentValve::VentValve(VESSEL *i_vessel,vector3 i_p,vector3 i_dir,float w,float h, {pos=i_p; dir=i_dir.normalize(); //need a way to inquire force for a vessel vessel=i_vessel; ph=vessel->CreatePropellantResource(0.005); - th=vessel->CreateThruster(_V(pos.x,pos.y,pos.z),_V(dir.x,dir.y,dir.z),10*MaxF,ph,1e99); + th=vessel->CreateThruster({pos.x,pos.y,pos.z},{dir.x,dir.y,dir.z},10*MaxF,ph,1e99); vessel->AddExhaust(th,w,h); }; void VentValve::Set(VESSEL *i_vessel,vector3 i_p,vector3 i_dir,float w,float h ,int i_open,int ct,float i_maxf, Valve *i_src) @@ -424,7 +424,7 @@ void VentValve::Set(VESSEL *i_vessel,vector3 i_p,vector3 i_dir,float w,float h , pos=i_p; dir=i_dir.normalize(); //need a way to inquire force for a vessel vessel=i_vessel; ph=vessel->CreatePropellantResource(0.005); - th=vessel->CreateThruster(_V(pos.x,pos.y,pos.z),_V(dir.x,dir.y,dir.z),10*MaxF,ph,1e99); + th=vessel->CreateThruster({pos.x,pos.y,pos.z},{dir.x,dir.y,dir.z},10*MaxF,ph,1e99); vessel->AddExhaust(th,w,h); }; diff --git a/Src/Vessel/Dragonfly/instruments.cpp b/Src/Vessel/Dragonfly/instruments.cpp index 413fbf296..3564a88ab 100644 --- a/Src/Vessel/Dragonfly/instruments.cpp +++ b/Src/Vessel/Dragonfly/instruments.cpp @@ -1172,7 +1172,7 @@ vector3 Vpos,Vvel,Vnorm; Vvel=_vector3(vel2.x,vel2.y,vel2.z);//this is V vector in local frame Vvel.selfnormalize(); Vnorm.x+=gpos.x;Vnorm.y+=gpos.y;Vnorm.z+=gpos.z; - parent->v->Global2Local(_V(Vnorm.x,Vnorm.y,Vnorm.z),vel2); + parent->v->Global2Local({Vnorm.x,Vnorm.y,Vnorm.z},vel2); Vnorm=_vector3(vel2.x,vel2.y,vel2.z);//and this is N vector in local frame Vnorm.selfnormalize(); diff --git a/Src/Vessel/HST/HST.cpp b/Src/Vessel/HST/HST.cpp index 1604a68a1..a7945d675 100644 --- a/Src/Vessel/HST/HST.cpp +++ b/Src/Vessel/HST/HST.cpp @@ -45,16 +45,16 @@ void HST::DefineAnimations (void) { // 1. Hi-gain antenna static UINT HiGainAnt1Grp[2] = {1,3}; - static MGROUP_ROTATE HiGainAnt1 (0, HiGainAnt1Grp, 2, _V(0.002579,1.993670,0.238158), _V(-1,0,0), (float)(PI*0.51)); + static MGROUP_ROTATE HiGainAnt1 (0, HiGainAnt1Grp, 2, {0.002579,1.993670,0.238158}, {-1,0,0}, (float)(PI*0.51)); static UINT HiGainAnt2Grp[2] = {0,2}; - static MGROUP_ROTATE HiGainAnt2 (0, HiGainAnt2Grp, 2, _V(0.002740,-2.013091,0.238118), _V(1,0,0), (float)(PI*0.51)); + static MGROUP_ROTATE HiGainAnt2 (0, HiGainAnt2Grp, 2, {0.002740,-2.013091,0.238118}, {1,0,0}, (float)(PI*0.51)); anim_ant = CreateAnimation (0.0196); AddAnimationComponent (anim_ant, 0, 0.5, &HiGainAnt1); AddAnimationComponent (anim_ant, 0, 1, &HiGainAnt2); // 2. Main telescope hatch static UINT HatchGrp[1] = {86}; - static MGROUP_ROTATE Hatch (0, HatchGrp, 1, _V(0.089688,1.456229,7.526453), _V(-1,0,0), (float)(RAD*113)); + static MGROUP_ROTATE Hatch (0, HatchGrp, 1, {0.089688,1.456229,7.526453}, {-1,0,0}, (float)(RAD*113)); anim_hatch = CreateAnimation (0); AddAnimationComponent (anim_hatch, 0, 1, &Hatch); @@ -62,17 +62,17 @@ void HST::DefineAnimations (void) anim_array = CreateAnimation (1); static UINT ArrayLFoldGrp[5] = {87,88,89,90,103}; static UINT ArrayRFoldGrp[5] = {92,93,94,95,102}; - static MGROUP_ROTATE ArrayLFold1 (0, ArrayLFoldGrp, 5, _V(-1.9, 0.053583,1.429349), _V(0,-1,0), (float)(PI*0.5)); + static MGROUP_ROTATE ArrayLFold1 (0, ArrayLFoldGrp, 5, {-1.9, 0.053583,1.429349}, {0,-1,0}, (float)(PI*0.5)); AddAnimationComponent (anim_array, 0, 0.4, &ArrayLFold1); - static MGROUP_ROTATE ArrayLFold2 (0, ArrayLFoldGrp, 5, _V(0,0.053583,1.429349), _V(-1,0,0), (float)(PI*0.5)); + static MGROUP_ROTATE ArrayLFold2 (0, ArrayLFoldGrp, 5, {0,0.053583,1.429349}, {-1,0,0}, (float)(PI*0.5)); AddAnimationComponent (anim_array, 0.4, 0.6, &ArrayLFold2); - static MGROUP_SCALE ArrayLFold3 (0, ArrayLFoldGrp, 4, _V(0,0.053583,1.429349), _V(1,1,4)); + static MGROUP_SCALE ArrayLFold3 (0, ArrayLFoldGrp, 4, {0,0.053583,1.429349}, {1,1,4}); AddAnimationComponent (anim_array, 0.6, 1, &ArrayLFold3); - static MGROUP_ROTATE ArrayRFold1 (0, ArrayRFoldGrp, 5, _V( 1.9, 0.053583,1.429349), _V(0, 1,0), (float)(PI*0.5)); + static MGROUP_ROTATE ArrayRFold1 (0, ArrayRFoldGrp, 5, { 1.9, 0.053583,1.429349}, {0, 1,0}, (float)(PI*0.5)); AddAnimationComponent (anim_array, 0, 0.4, &ArrayRFold1); - static MGROUP_ROTATE ArrayRFold2 (0, ArrayRFoldGrp, 5, _V(0,0.053583,1.429349), _V(-1,0,0), (float)(PI*0.5)); + static MGROUP_ROTATE ArrayRFold2 (0, ArrayRFoldGrp, 5, {0,0.053583,1.429349}, {-1,0,0}, (float)(PI*0.5)); AddAnimationComponent (anim_array, 0.4, 0.6, &ArrayRFold2); - static MGROUP_SCALE ArrayRFold3 (0, ArrayRFoldGrp, 4, _V(0,0.053583,1.429349), _V(1,1,4)); + static MGROUP_SCALE ArrayRFold3 (0, ArrayRFoldGrp, 4, {0,0.053583,1.429349}, {1,1,4}); AddAnimationComponent (anim_array, 0.6, 1, &ArrayRFold3); } diff --git a/Src/Vessel/MMU/mmu.cpp b/Src/Vessel/MMU/mmu.cpp index 532c02284..5469753f8 100644 --- a/Src/Vessel/MMU/mmu.cpp +++ b/Src/Vessel/MMU/mmu.cpp @@ -46,124 +46,124 @@ void AddAttitudeJets(VESSEL *vessel) main_tank = vessel->CreatePropellantResource(11.8); - m_exhaust_pos= _V(.37,0.64,-.22); - m_exhaust_ref = _V(0,0,1); + m_exhaust_pos= {.37,0.64,-.22}; + m_exhaust_ref = {0,0,1}; thruster[0] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[0],0.2,0.01); - m_exhaust_pos= _V(-.37,0.64,-.22); - m_exhaust_ref = _V(0,0,1); + m_exhaust_pos= {-.37,0.64,-.22}; + m_exhaust_ref = {0,0,1}; thruster[6] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[6],0.2,0.01); - m_exhaust_pos= _V(.37,-0.64,-.22); - m_exhaust_ref = _V(0,0,1); + m_exhaust_pos= {.37,-0.64,-.22}; + m_exhaust_ref = {0,0,1}; thruster[12] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[12],0.2,0.01); - m_exhaust_pos= _V(-.37,-0.64,-.22); - m_exhaust_ref = _V(0,0,1); + m_exhaust_pos= {-.37,-0.64,-.22}; + m_exhaust_ref = {0,0,1}; thruster[18] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[18],0.2,0.01); - m_exhaust_pos= _V(.37,.64,0.22); - m_exhaust_ref = _V(0,0,-1); + m_exhaust_pos= {.37,.64,0.22}; + m_exhaust_ref = {0,0,-1}; thruster[1] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[1],0.2,0.01); - m_exhaust_pos= _V(-.37,0.64, 0.22); - m_exhaust_ref = _V(0,0,-1); + m_exhaust_pos= {-.37,0.64, 0.22}; + m_exhaust_ref = {0,0,-1}; thruster[7] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[7],0.2,0.01); - m_exhaust_pos= _V(.37,-0.64,0.22); - m_exhaust_ref = _V(0,0,-1); + m_exhaust_pos= {.37,-0.64,0.22}; + m_exhaust_ref = {0,0,-1}; thruster[13] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[13],0.2,0.01); - m_exhaust_pos= _V(-.37,-0.64,0.22); - m_exhaust_ref = _V(0,0,-1); + m_exhaust_pos= {-.37,-0.64,0.22}; + m_exhaust_ref = {0,0,-1}; thruster[19] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[19],0.2,0.01); - m_exhaust_pos= _V(.40,.64,0.17); - m_exhaust_ref = _V(-1,0,0); + m_exhaust_pos= {.40,.64,0.17}; + m_exhaust_ref = {-1,0,0}; thruster[2] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[2],0.2,0.01); - m_exhaust_pos= _V(.40,.64,-0.17); - m_exhaust_ref = _V(-1,0,0); + m_exhaust_pos= {.40,.64,-0.17}; + m_exhaust_ref = {-1,0,0}; thruster[3] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[3],0.2,0.01); - m_exhaust_pos= _V(.37,.68,0.17); - m_exhaust_ref = _V(0,-1,0); + m_exhaust_pos= {.37,.68,0.17}; + m_exhaust_ref = {0,-1,0}; thruster[4] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[4],0.2,0.01); - m_exhaust_pos= _V(.37,.68,-0.17); - m_exhaust_ref = _V(0,-1,0); + m_exhaust_pos= {.37,.68,-0.17}; + m_exhaust_ref = {0,-1,0}; thruster[5] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[5],0.2,0.01); - m_exhaust_pos= _V(-.40,0.64, 0.17); - m_exhaust_ref = _V(1,0,0); + m_exhaust_pos= {-.40,0.64, 0.17}; + m_exhaust_ref = {1,0,0}; thruster[8] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[8],0.2,0.01); - m_exhaust_pos= _V(-.40,0.64, -0.17); - m_exhaust_ref = _V(1,0,0); + m_exhaust_pos= {-.40,0.64, -0.17}; + m_exhaust_ref = {1,0,0}; thruster[9] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[9],0.2,0.01); - m_exhaust_pos= _V(-.37,0.68, 0.17); - m_exhaust_ref = _V(0,-1,0); + m_exhaust_pos= {-.37,0.68, 0.17}; + m_exhaust_ref = {0,-1,0}; thruster[10] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[10],0.2,0.01); - m_exhaust_pos= _V(-.37,0.68, -0.17); - m_exhaust_ref = _V(0,-1,0); + m_exhaust_pos= {-.37,0.68, -0.17}; + m_exhaust_ref = {0,-1,0}; thruster[11] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[11],0.2,0.01); - m_exhaust_pos= _V(.40,-0.64,0.17); - m_exhaust_ref = _V(-1,0,0); + m_exhaust_pos= {.40,-0.64,0.17}; + m_exhaust_ref = {-1,0,0}; thruster[14] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[14],0.2,0.01); - m_exhaust_pos= _V(.40,-0.64,-0.17); - m_exhaust_ref = _V(-1,0,0); + m_exhaust_pos= {.40,-0.64,-0.17}; + m_exhaust_ref = {-1,0,0}; thruster[15] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[15],0.2,0.01); - m_exhaust_pos= _V(.37,-0.68,0.17); - m_exhaust_ref = _V(0,1,0); + m_exhaust_pos= {.37,-0.68,0.17}; + m_exhaust_ref = {0,1,0}; thruster[16] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[16],0.2,0.01); - m_exhaust_pos= _V(.37,-0.68,-0.17); - m_exhaust_ref = _V(0,1,0); + m_exhaust_pos= {.37,-0.68,-0.17}; + m_exhaust_ref = {0,1,0}; thruster[17] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[17],0.2,0.01); - m_exhaust_pos= _V(-.40,-0.68,0.17); - m_exhaust_ref = _V(1,0,0); + m_exhaust_pos= {-.40,-0.68,0.17}; + m_exhaust_ref = {1,0,0}; thruster[20] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[20],0.2,0.01); - m_exhaust_pos= _V(-.40,-0.68,-0.17); - m_exhaust_ref = _V(1,0,0); + m_exhaust_pos= {-.40,-0.68,-0.17}; + m_exhaust_ref = {1,0,0}; thruster[21] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[21],0.2,0.01); - m_exhaust_pos= _V(-.37,-0.68,0.17); - m_exhaust_ref = _V(0,1,0); + m_exhaust_pos= {-.37,-0.68,0.17}; + m_exhaust_ref = {0,1,0}; thruster[22] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[22],0.2,0.01); - m_exhaust_pos= _V(-.37,-0.68,-0.17); - m_exhaust_ref = _V(0,1,0); + m_exhaust_pos= {-.37,-0.68,-0.17}; + m_exhaust_ref = {0,1,0}; thruster[23] = vessel->CreateThruster(m_exhaust_pos, m_exhaust_ref, JET_THRUST, main_tank, JET_ISP); vessel->AddExhaust(thruster[23],0.2,0.01); @@ -263,15 +263,15 @@ void SetMMU (VESSEL *vessel) // vessel->SetMaxThrust (ENGINE_HOVER, 0); // vessel->SetMaxThrust (ENGINE_ATTITUDE, 31.5); // ============================================================== - vessel->SetPMI (_V(.35,.13,0.35)); - vessel->SetCrossSections (_V(1.64,.77,1.64)); + vessel->SetPMI ({.35,.13,0.35}); + vessel->SetCrossSections ({1.64,.77,1.64}); // ============================================================== vessel->SetCW (0.3, 0.3, .3, .3); - vessel->SetRotDrag (_V(0.7,0.7,1.2)); + vessel->SetRotDrag ({0.7,0.7,1.2}); vessel->SetPitchMomentScale (0); vessel->SetYawMomentScale (0); vessel->SetLiftCoeffFunc (0); - vessel->SetDockParams (_V(0,0,.44), _V(0,0,1), _V(0,1,0)); + vessel->SetDockParams ({0,0,.44}, {0,0,1}, {0,1,0}); // ============================================================== vessel->ClearMeshes(); @@ -279,12 +279,12 @@ void SetMMU (VESSEL *vessel) vessel->ClearAttExhaustRefs(); vessel->ClearPropellantResources(); vessel->ClearThrusterDefinitions(); - mesh_pos = _V(0,-0.24,0.16); + mesh_pos = {0,-0.24,0.16}; vessel->AddMesh("mmu", &mesh_pos); AddAttitudeJets(vessel); - vessel->SetDockParams(_V(0,0,0.5),_V(0,0,1),_V(0,1,0)); - //vessel->SetDockParams(_V(0,0,0),_V(0,-1,0),_V(0,0,1)); - //vessel->CreateDock(_V(0,0,0.22),_V(0,0,1),_V(0,1,0)); + vessel->SetDockParams({0,0,0.5},{0,0,1},{0,1,0}); + //vessel->SetDockParams({0,0,0},{0,-1,0},{0,0,1}); + //vessel->CreateDock({0,0,0.22},{0,0,1},{0,1,0}); } diff --git a/Src/Vessel/Quadcopter/PropulsionSubsys.cpp b/Src/Vessel/Quadcopter/PropulsionSubsys.cpp index c414d905f..987532fdc 100644 --- a/Src/Vessel/Quadcopter/PropulsionSubsys.cpp +++ b/Src/Vessel/Quadcopter/PropulsionSubsys.cpp @@ -37,9 +37,9 @@ Rotor::Rotor(const PropulsionSubsystem *ssys, const VECTOR3 &pos, SpinDirection , m_spin(spin) , m_throttle(0.0) { - m_liftDir = _V(0, 1, 0); + m_liftDir = {0, 1, 0}; VECTOR3 cgDir = unit(-pos); - m_torqueDir = crossp(cgDir, m_liftDir); + m_torqueDir = cross(cgDir, m_liftDir); if (spin == SPIN_RIGHT) m_torqueDir = -m_torqueDir; } @@ -75,10 +75,10 @@ PropulsionSubsystem::PropulsionSubsystem(Quadcopter *qc) { const double px = 0.4, pz = 0.4, py = 0.15; - m_rotor[ROTOR_FL] = new Rotor(this, _V(-px, py, pz), Rotor::SPIN_LEFT); - m_rotor[ROTOR_FR] = new Rotor(this, _V( px, py, pz), Rotor::SPIN_RIGHT); - m_rotor[ROTOR_BL] = new Rotor(this, _V(-px, py, -pz), Rotor::SPIN_RIGHT); - m_rotor[ROTOR_BR] = new Rotor(this, _V( px, py, -pz), Rotor::SPIN_LEFT); + m_rotor[ROTOR_FL] = new Rotor(this, {-px, py, pz}, Rotor::SPIN_LEFT); + m_rotor[ROTOR_FR] = new Rotor(this, { px, py, pz}, Rotor::SPIN_RIGHT); + m_rotor[ROTOR_BL] = new Rotor(this, {-px, py, -pz}, Rotor::SPIN_RIGHT); + m_rotor[ROTOR_BR] = new Rotor(this, { px, py, -pz}, Rotor::SPIN_LEFT); m_holdActive = false; m_throttle = 0.0; @@ -166,7 +166,7 @@ void PropulsionSubsystem::clbkPreStep(double simt, double simdt, double mjd) if (m_autoHeading) { VECTOR3 v; QC()->GetHorizonAirspeedVector(v); - if (length(v) > 5.0) { + if (len(v) > 5.0) { double course = atan2(v.x, v.z); SetHeading(course, dy); fixedHeading = true; diff --git a/Src/Vessel/Quadcopter/Quadcopter.cpp b/Src/Vessel/Quadcopter/Quadcopter.cpp index 8a3a02fea..d73b7d827 100644 --- a/Src/Vessel/Quadcopter/Quadcopter.cpp +++ b/Src/Vessel/Quadcopter/Quadcopter.cpp @@ -22,24 +22,24 @@ Quadcopter::Quadcopter(OBJHANDLE hObj, int fmodel) void Quadcopter::clbkSetClassCaps(FILEHANDLE cfg) { const TOUCHDOWNVTX tdv[12] = { - { _V(-0.3, -0.26, 0.3), 1e3, 5e1, 1.6, 1.6 }, - { _V(-0.3, -0.26, -0.3), 1e3, 5e1, 1.6, 1.6 }, - { _V( 0.3, -0.26, -0.3), 1e3, 5e1, 1.6, 1.6 }, - { _V( 0.3, -0.26, 0.3), 1e3, 5e1, 1.6 }, - { _V( 0.6, 0.15, 0.4), 1e3, 5e1, 1.6 }, - { _V( 0.6, 0.15, -0.4), 1e3, 5e1, 1.6 }, - { _V(-0.6, 0.15, 0.4), 1e3, 5e1, 1.6 }, - { _V(-0.6, 0.15, -0.4), 1e3, 5e1, 1.6 }, - { _V( 0.4, 0.15, 0.6), 1e3, 5e1, 1.6 }, - { _V(-0.4, 0.15, 0.6), 1e3, 5e1, 1.6 }, - { _V( 0.4, 0.15, -0.6), 1e3, 5e1, 1.6 }, - { _V(-0.4, 0.15, -0.6), 1e3, 5e1, 1.6 } + { {-0.3, -0.26, 0.3}, 1e3, 5e1, 1.6, 1.6 }, + { {-0.3, -0.26, -0.3}, 1e3, 5e1, 1.6, 1.6 }, + { { 0.3, -0.26, -0.3}, 1e3, 5e1, 1.6, 1.6 }, + { { 0.3, -0.26, 0.3}, 1e3, 5e1, 1.6 }, + { { 0.6, 0.15, 0.4}, 1e3, 5e1, 1.6 }, + { { 0.6, 0.15, -0.4}, 1e3, 5e1, 1.6 }, + { {-0.6, 0.15, 0.4}, 1e3, 5e1, 1.6 }, + { {-0.6, 0.15, -0.4}, 1e3, 5e1, 1.6 }, + { { 0.4, 0.15, 0.6}, 1e3, 5e1, 1.6 }, + { {-0.4, 0.15, 0.6}, 1e3, 5e1, 1.6 }, + { { 0.4, 0.15, -0.6}, 1e3, 5e1, 1.6 }, + { {-0.4, 0.15, -0.6}, 1e3, 5e1, 1.6 } }; SetEmptyMass(2.0); SetSize(0.3); - SetPMI(_V(0.02, 0.05, 0.02)); - SetCrossSections(_V(0.1, 0.6, 0.1)); + SetPMI({0.02, 0.05, 0.02}); + SetCrossSections({0.1, 0.6, 0.1}); SetCW(1.0, 1.0, 1.0, 1.0); SetTouchdownPoints(tdv, 12); exmesh_tpl = oapiLoadMeshGlobal("Quadcopter\\quadcopter"); @@ -48,7 +48,7 @@ void Quadcopter::clbkSetClassCaps(FILEHANDLE cfg) // Dummy thruster ph = CreatePropellantResource(0.01, 0.01); SetDefaultPropellantResource(ph); - th = CreateThruster(_V(0, 0, 0), _V(0, 1, 0), 1e-10, ph, 1e-5, 1e-5); + th = CreateThruster({0, 0, 0}, {0, 1, 0}, 1e-10, ph, 1e-5, 1e-5); tgh = CreateThrusterGroup(&th, 1, THGROUP_MAIN); } diff --git a/Src/Vessel/ShuttleA/ShuttleA.cpp b/Src/Vessel/ShuttleA/ShuttleA.cpp index 931102398..db330bddd 100644 --- a/Src/Vessel/ShuttleA/ShuttleA.cpp +++ b/Src/Vessel/ShuttleA/ShuttleA.cpp @@ -48,22 +48,22 @@ GDIParams g_Param; static const int ntdvtx = 16; static TOUCHDOWNVTX tdvtx[ntdvtx] = { - {_V(-3 ,-3.05, 12.5), 3.5e6, 3.5e5, 3}, - {_V(-3 ,-3.05,-13.5), 3e6, 3e5, 3}, - {_V( 3 ,-3.05,-13.5), 3e6, 3e5, 3}, - {_V( 3 ,-3.05, 12.5), 3.5e6, 3.5e5, 3}, - {_V(-7.7, 0 ,-0.4 ), 3e7, 3e6, 3}, - {_V( 7.7, 0 ,-0.4 ), 3e7, 3e6, 3}, - {_V(-1.5, 3 ,13.5 ), 3e7, 3e6, 3}, - {_V( 1.5, 3 ,13.5 ), 3e7, 3e6, 3}, - {_V(-1.3, 2.8 ,17 ), 3e7, 3e6, 3}, - {_V( 1.3, 2.8 ,17 ), 3e7, 3e6, 3}, - {_V(-1.8, 0 ,18.3 ), 3e7, 3e6, 3}, - {_V( 1.8, 0 ,18.3 ), 3e7, 3e6, 3}, - {_V(-1.9, 2.2 ,-13.8), 3e7, 3e6, 3}, - {_V( 1.9, 2.2 ,-13.8), 3e7, 3e6, 3}, - {_V(-3.3, 0 ,-14.9), 3e7, 3e6, 3}, - {_V( 3.3, 0 ,-14.9), 3e7, 3e6, 3} + {{-3 ,-3.05, 12.5}, 3.5e6, 3.5e5, 3}, + {{-3 ,-3.05,-13.5}, 3e6, 3e5, 3}, + {{ 3 ,-3.05,-13.5}, 3e6, 3e5, 3}, + {{ 3 ,-3.05, 12.5}, 3.5e6, 3.5e5, 3}, + {{-7.7, 0 ,-0.4 }, 3e7, 3e6, 3}, + {{ 7.7, 0 ,-0.4 }, 3e7, 3e6, 3}, + {{-1.5, 3 ,13.5 }, 3e7, 3e6, 3}, + {{ 1.5, 3 ,13.5 }, 3e7, 3e6, 3}, + {{-1.3, 2.8 ,17 }, 3e7, 3e6, 3}, + {{ 1.3, 2.8 ,17 }, 3e7, 3e6, 3}, + {{-1.8, 0 ,18.3 }, 3e7, 3e6, 3}, + {{ 1.8, 0 ,18.3 }, 3e7, 3e6, 3}, + {{-1.9, 2.2 ,-13.8}, 3e7, 3e6, 3}, + {{ 1.9, 2.2 ,-13.8}, 3e7, 3e6, 3}, + {{-3.3, 0 ,-14.9}, 3e7, 3e6, 3}, + {{ 3.3, 0 ,-14.9}, 3e7, 3e6, 3} }; // ============================================================== @@ -156,10 +156,10 @@ ShuttleA::~ShuttleA () void ShuttleA::DefineAnimations () { static UINT LeftPodGrp[4] = {4,5,7,9}; - static MGROUP_ROTATE leftpod(0,LeftPodGrp,4,_V(0,0,0),_V(1,0,0),(float)PI); + static MGROUP_ROTATE leftpod(0,LeftPodGrp,4,{0,0,0},{1,0,0},(float)PI); static UINT RightPodGrp[4] = {6,8,10,11}; - static MGROUP_ROTATE rightpod(0,RightPodGrp,4,_V(0,0,0),_V(1,0,0),(float)PI); + static MGROUP_ROTATE rightpod(0,RightPodGrp,4,{0,0,0},{1,0,0},(float)PI); // Register animation for hover/retro pods anim_pod[0] = CreateAnimation (0); @@ -168,22 +168,22 @@ void ShuttleA::DefineAnimations () AddAnimationComponent (anim_pod[1], 0.0f,1.0f,&rightpod); static UINT UpperDockHatch = 19; - static MGROUP_ROTATE upperhatch(0,&UpperDockHatch,1,_V(0,0.554f,18.677401f),_V(-1,0,0),(float)PI); + static MGROUP_ROTATE upperhatch(0,&UpperDockHatch,1,{0,0.554f,18.677401f},{-1,0,0},(float)PI); static UINT LowerDockHatch = 18; - static MGROUP_ROTATE lowerhatch(0,&LowerDockHatch,1,_V(0,-0.554f,18.677401f),_V(1,0,0),(float)PI); + static MGROUP_ROTATE lowerhatch(0,&LowerDockHatch,1,{0,-0.554f,18.677401f},{1,0,0},(float)PI); anim_dock = CreateAnimation (0); AddAnimationComponent (anim_dock,0.0f,1.0f, &upperhatch); AddAnimationComponent (anim_dock,0.2f,1.0f, &lowerhatch); // outer airlock static UINT OuterAirlock_groups = GRP_Docking_Hatch; - static MGROUP_ROTATE OuterAirlock_anim(0, &OuterAirlock_groups, 1, _V(0.498895f, 0.0f, 18.6131f), _V(0, -1, 0), (float)(0.51f*PI)); + static MGROUP_ROTATE OuterAirlock_anim(0, &OuterAirlock_groups, 1, {0.498895f, 0.0f, 18.6131f}, {0, -1, 0}, (float)(0.51f*PI)); anim_lock[0] = CreateAnimation (0); AddAnimationComponent (anim_lock[0], 0.0f ,1.0f, &OuterAirlock_anim); // inner airlock static UINT InnerAirlock_groups = GRP_Airlock_Hatch; - static MGROUP_ROTATE InnerAirlock_anim(0, &InnerAirlock_groups, 1, _V(-0.4102f, 0.0f, 16.5474f), _V(0, -1, 0), (float)(0.55f * PI)); + static MGROUP_ROTATE InnerAirlock_anim(0, &InnerAirlock_groups, 1, {-0.4102f, 0.0f, 16.5474f}, {0, -1, 0}, (float)(0.55f * PI)); anim_lock[1] = CreateAnimation (0); AddAnimationComponent(anim_lock[1], 0.0f, 1.0f, &InnerAirlock_anim); @@ -198,17 +198,17 @@ void ShuttleA::DefineAnimations () static UINT GEAR_left_leg_back_p1=36; static UINT GEAR_left_leg_back_p2=23; - static MGROUP_TRANSLATE MGEAR_left_leg_first (0, GEAR_left_leg, 3, _V(-0.194,0.224,0.0)); - static MGROUP_TRANSLATE MGEAR_left_leg_second (0, GEAR_left_leg, 3, _V(-0.091,0.331,0.0)); - static MGROUP_TRANSLATE MGEAR_right_leg_first (0, GEAR_right_leg, 3, _V(0.194,0.224,0.0)); - static MGROUP_TRANSLATE MGEAR_right_leg_second (0, GEAR_right_leg, 3, _V(0.091,0.331,0.0)); + static MGROUP_TRANSLATE MGEAR_left_leg_first (0, GEAR_left_leg, 3, {-0.194,0.224,0.0}); + static MGROUP_TRANSLATE MGEAR_left_leg_second (0, GEAR_left_leg, 3, {-0.091,0.331,0.0}); + static MGROUP_TRANSLATE MGEAR_right_leg_first (0, GEAR_right_leg, 3, {0.194,0.224,0.0}); + static MGROUP_TRANSLATE MGEAR_right_leg_second (0, GEAR_right_leg, 3, {0.091,0.331,0.0}); - static MGROUP_ROTATE MGEAR_left_leg_front_p1(0,&GEAR_left_leg_front_p1,1,_V(-1.655f,-1.942f,0.0f),_V(0,0,-1),0.9948f); - static MGROUP_ROTATE MGEAR_left_leg_front_p2(0,&GEAR_left_leg_front_p2,1,_V(-1.112f,-1.718f,0.0f),_V(0,0,-1),0.5235f); - static MGROUP_ROTATE MGEAR_left_leg_mid_p1(0,&GEAR_left_leg_mid_p1,1,_V(-3.007f,-1.942f,0.0f),_V(0,0,-1),0.9948f); - static MGROUP_ROTATE MGEAR_left_leg_mid_p2(0,&GEAR_left_leg_mid_p2,1,_V(-2.464f,-1.718f,0.0f),_V(0,0,-1),0.5235f); - static MGROUP_ROTATE MGEAR_left_leg_back_p1(0,&GEAR_left_leg_back_p1,1,_V(-2.49f,-1.942f,0.0f),_V(0,0,-1),0.9948f); - static MGROUP_ROTATE MGEAR_left_leg_back_p2(0,&GEAR_left_leg_back_p2,1,_V(-1.947f,-1.718f,0.0f),_V(0,0,-1),0.5235f); + static MGROUP_ROTATE MGEAR_left_leg_front_p1(0,&GEAR_left_leg_front_p1,1,{-1.655f,-1.942f,0.0f},{0,0,-1},0.9948f); + static MGROUP_ROTATE MGEAR_left_leg_front_p2(0,&GEAR_left_leg_front_p2,1,{-1.112f,-1.718f,0.0f},{0,0,-1},0.5235f); + static MGROUP_ROTATE MGEAR_left_leg_mid_p1(0,&GEAR_left_leg_mid_p1,1,{-3.007f,-1.942f,0.0f},{0,0,-1},0.9948f); + static MGROUP_ROTATE MGEAR_left_leg_mid_p2(0,&GEAR_left_leg_mid_p2,1,{-2.464f,-1.718f,0.0f},{0,0,-1},0.5235f); + static MGROUP_ROTATE MGEAR_left_leg_back_p1(0,&GEAR_left_leg_back_p1,1,{-2.49f,-1.942f,0.0f},{0,0,-1},0.9948f); + static MGROUP_ROTATE MGEAR_left_leg_back_p2(0,&GEAR_left_leg_back_p2,1,{-1.947f,-1.718f,0.0f},{0,0,-1},0.5235f); static UINT GEAR_right_leg_front_p1=39; static UINT GEAR_right_leg_front_p2=26; @@ -217,12 +217,12 @@ void ShuttleA::DefineAnimations () static UINT GEAR_right_leg_back_p1=37; static UINT GEAR_right_leg_back_p2=24; - static MGROUP_ROTATE MGEAR_right_leg_front_p1(0,&GEAR_right_leg_front_p1,1,_V(1.655f,-1.942f,0.0f),_V(0,0,1),0.9948f); - static MGROUP_ROTATE MGEAR_right_leg_front_p2(0,&GEAR_right_leg_front_p2,1,_V(1.112f,-1.718f,0.0f),_V(0,0,1),0.5235f); - static MGROUP_ROTATE MGEAR_right_leg_mid_p1(0,&GEAR_right_leg_mid_p1,1,_V(3.007f,-1.942f,0.0f),_V(0,0,1),0.9948f); - static MGROUP_ROTATE MGEAR_right_leg_mid_p2(0,&GEAR_right_leg_mid_p2,1,_V(2.464f,-1.718f,0.0f),_V(0,0,1),0.5235f); - static MGROUP_ROTATE MGEAR_right_leg_back_p1(0,&GEAR_right_leg_back_p1,1,_V(2.49f,-1.942f,0.0f),_V(0,0,1),0.9948f); - static MGROUP_ROTATE MGEAR_right_leg_back_p2(0,&GEAR_right_leg_back_p2,1,_V(1.947f,-1.718f,0.0f),_V(0,0,1),0.5235f); + static MGROUP_ROTATE MGEAR_right_leg_front_p1(0,&GEAR_right_leg_front_p1,1,{1.655f,-1.942f,0.0f},{0,0,1},0.9948f); + static MGROUP_ROTATE MGEAR_right_leg_front_p2(0,&GEAR_right_leg_front_p2,1,{1.112f,-1.718f,0.0f},{0,0,1},0.5235f); + static MGROUP_ROTATE MGEAR_right_leg_mid_p1(0,&GEAR_right_leg_mid_p1,1,{3.007f,-1.942f,0.0f},{0,0,1},0.9948f); + static MGROUP_ROTATE MGEAR_right_leg_mid_p2(0,&GEAR_right_leg_mid_p2,1,{2.464f,-1.718f,0.0f},{0,0,1},0.5235f); + static MGROUP_ROTATE MGEAR_right_leg_back_p1(0,&GEAR_right_leg_back_p1,1,{2.49f,-1.942f,0.0f},{0,0,1},0.9948f); + static MGROUP_ROTATE MGEAR_right_leg_back_p2(0,&GEAR_right_leg_back_p2,1,{1.947f,-1.718f,0.0f},{0,0,1},0.5235f); anim_gear = CreateAnimation(0.0); AddAnimationComponent (anim_gear, 0.0f, 0.5f, &MGEAR_left_leg_first); @@ -248,8 +248,8 @@ void ShuttleA::DefineAnimations () //auxiliary thrusters static UINT POD_thruster_left[1] = {22}; static UINT POD_thruster_right[1] = {30}; - static MGROUP_TRANSLATE MPOD_thruster_left (1, POD_thruster_left, 1, _V(0,0.05,0.023)); - static MGROUP_TRANSLATE MPOD_thruster_right (1, POD_thruster_right, 1, _V(0,0.05,0.023)); + static MGROUP_TRANSLATE MPOD_thruster_left (1, POD_thruster_left, 1, {0,0.05,0.023}); + static MGROUP_TRANSLATE MPOD_thruster_right (1, POD_thruster_right, 1, {0,0.05,0.023}); anim_pod_thrust_left = CreateAnimation (0); AddAnimationComponent (anim_pod_thrust_left, 0, 1.0, &MPOD_thruster_left); @@ -259,8 +259,8 @@ void ShuttleA::DefineAnimations () //hover thrusters static UINT HOVER_thruster_left[1]={31}; static UINT HOVER_thruster_right[1]={32}; - static MGROUP_TRANSLATE MHOVER_thruster_left(1,HOVER_thruster_left,1,_V(0,0.085,0.037)); - static MGROUP_TRANSLATE MHOVER_thruster_right(1,HOVER_thruster_right,1,_V(0,0.085,0.037)); + static MGROUP_TRANSLATE MHOVER_thruster_left(1,HOVER_thruster_left,1,{0,0.085,0.037}); + static MGROUP_TRANSLATE MHOVER_thruster_right(1,HOVER_thruster_right,1,{0,0.085,0.037}); anim_hover_thrust_left= CreateAnimation(0); AddAnimationComponent (anim_hover_thrust_left, 0, 1.0, &MHOVER_thruster_left); @@ -270,8 +270,8 @@ void ShuttleA::DefineAnimations () //main thrusters static UINT MAIN_thruster_left[1]={27}; static UINT MAIN_thruster_right[1]={28}; - static MGROUP_TRANSLATE MMAIN_thruster_left (1,MAIN_thruster_left,1,_V(0,0.085,0.037)); - static MGROUP_TRANSLATE MMAIN_thruster_right (1,MAIN_thruster_right,1,_V(0,0.085,0.037)); + static MGROUP_TRANSLATE MMAIN_thruster_left (1,MAIN_thruster_left,1,{0,0.085,0.037}); + static MGROUP_TRANSLATE MMAIN_thruster_right (1,MAIN_thruster_right,1,{0,0.085,0.037}); anim_main_thrust_left = CreateAnimation (0); AddAnimationComponent (anim_main_thrust_left, 0, 1.0, &MMAIN_thruster_left); @@ -280,43 +280,43 @@ void ShuttleA::DefineAnimations () // POD angle switch static UINT POD_angle_switch[2]={34,35}; - static MGROUP_ROTATE MPOD_angle_switch(1,POD_angle_switch,2,_V(-0.596666398f,1.98931781f,16.28778112f),//added 0.10 to Z - _V(0.996194179f,0.036831321f,-0.078997542f),1.570796327f); + static MGROUP_ROTATE MPOD_angle_switch(1,POD_angle_switch,2,{-0.596666398f,1.98931781f,16.28778112f},//added 0.10 to Z + {0.996194179f,0.036831321f,-0.078997542f},1.570796327f); anim_pod_angle= CreateAnimation(0.5); AddAnimationComponent(anim_pod_angle,0.0f,1.0f,&MPOD_angle_switch); // RCS mode switch static UINT RCS_mode_switch=33; - static MGROUP_ROTATE MRCS_mode_switch(1,&RCS_mode_switch,1,_V(-0.479842445f,2.100993049f,16.32856942f),//added 0.10 to Z - _V(0.996194179f,0.036831321f,-0.078997542f),1.570796327f); + static MGROUP_ROTATE MRCS_mode_switch(1,&RCS_mode_switch,1,{-0.479842445f,2.100993049f,16.32856942f},//added 0.10 to Z + {0.996194179f,0.036831321f,-0.078997542f},1.570796327f); anim_rcs_mode= CreateAnimation(0.5); AddAnimationComponent(anim_rcs_mode,0.0f,1.0f,&MRCS_mode_switch); //DOCK port switch static UINT DOCK_switch=39; - static MGROUP_ROTATE MDOCK_switch (1,&DOCK_switch,1,_V(-0.212890075f,2.608840923f,16.09495988f), - _V(0.0f,0.061554834f,-0.998103703f),1.570796327f/2.0f); + static MGROUP_ROTATE MDOCK_switch (1,&DOCK_switch,1,{-0.212890075f,2.608840923f,16.09495988f}, + {0.0f,0.061554834f,-0.998103703f},1.570796327f/2.0f); anim_dock_switch= CreateAnimation(0.5); AddAnimationComponent(anim_dock_switch,0.0f,1.0f,&MDOCK_switch); //AIRLOCK switch static UINT AIRLOCK_switch=41; - static MGROUP_ROTATE MAIRLOCK_switch (1,&AIRLOCK_switch,1,_V(-0.243815575f,2.639114618f,16.09778152f), - _V(0.0f,0.061554834f,-0.998103703f),1.570796327f/2.0f); + static MGROUP_ROTATE MAIRLOCK_switch (1,&AIRLOCK_switch,1,{-0.243815575f,2.639114618f,16.09778152f}, + {0.0f,0.061554834f,-0.998103703f},1.570796327f/2.0f); anim_airlock_switch = CreateAnimation(0.5); AddAnimationComponent(anim_airlock_switch,0.0f,1.0f,&MAIRLOCK_switch); //GEAR switch static UINT GEAR_switch=49; - static MGROUP_ROTATE MGEAR_switch (1, &GEAR_switch,1, _V(-0.212890075f,2.610353215f,16.07043827f), - _V(0.0f,0.061554834f,-0.998103703f),1.570796327f/2.0f); + static MGROUP_ROTATE MGEAR_switch (1, &GEAR_switch,1, {-0.212890075f,2.610353215f,16.07043827f}, + {0.0f,0.061554834f,-0.998103703f},1.570796327f/2.0f); anim_gear_switch = CreateAnimation(0.5); AddAnimationComponent(anim_gear_switch,0.0f,1.0f,&MGEAR_switch); //CARGO ARM switch static UINT CARGO_switch=54; - static MGROUP_ROTATE MCARGO_switch (1, &CARGO_switch,1, _V(-0.212890075f,2.616076201f,15.97764079f), - _V(0.0f,0.061554834f,-0.998103703f),1.570796327f/2.0f); + static MGROUP_ROTATE MCARGO_switch (1, &CARGO_switch,1, {-0.212890075f,2.616076201f,15.97764079f}, + {0.0f,0.061554834f,-0.998103703f},1.570796327f/2.0f); anim_cargo_switch = CreateAnimation(0.5); AddAnimationComponent(anim_cargo_switch,0.0f,1.0f,&MCARGO_switch); } @@ -436,7 +436,7 @@ void ShuttleA::SetPodAngle (UINT which, double angle) if (which & (1<GlobalRot(rot,gcrot); v->GlobalRot(dir,gcdir); //should be normal by now - if ((dotp(grot,gcrot)>MAX_GRAPPLING_ANG)&&(dotp(gdir,gcdir)<-MAX_GRAPPLING_ANG))//dotrot=1 and dotdir=-1(same up vector, but opposing dir vectors) + if ((dot(grot, gcrot) > MAX_GRAPPLING_ANG) && (dot(gdir, gcdir) < -MAX_GRAPPLING_ANG))//dotrot=1 and dotdir=-1(same up vector, but opposing dir vectors) { AttachChild (hV, payload_attachment[grapple], hAtt); ComputePayloadMass(); @@ -1102,17 +1102,17 @@ void ShuttleA::clbkSetClassCaps (FILEHANDLE cfg) SetSize (17.0); SetClipRadius(19.0); - SetPMI (_V(86.6, 89.8, 5.5)); + SetPMI ({86.6, 89.8, 5.5}); SetEmptyMass (EMPTY_MASS); payload_mass = 0.0; VECTOR3 r[2] = {{0,0,8}, {0,0,-8}}; SetGravityGradientDamping (20.0); SetCW (0.2, 0.2, 1.5, 1.5); - SetCrossSections (_V(132.2, 237.9, 42.4)); - SetRotDrag (_V(0.7, 0.7, 0.3)); + SetCrossSections ({132.2, 237.9, 42.4}); + SetRotDrag ({0.7, 0.7, 0.3}); SetSurfaceFrictionCoeff (0.5, 0.5); - SetCameraOffset (_V(-0.575f,2.4f,15.9f)); - SetDockParams (_V(0,0,18.677), _V(0,0,1), _V(0,1,0)); + SetCameraOffset ({-0.575f,2.4f,15.9f}); + SetDockParams ({0,0,18.677}, {0,0,1}, {0,1,0}); SetTouchdownPoints (tdvtx, ntdvtx); @@ -1155,29 +1155,29 @@ void ShuttleA::clbkSetClassCaps (FILEHANDLE cfg) }; // main thrusters - th_main[0] = CreateThruster (_V(-1.7598,0,-13.8705), _V(0,0,1), MAX_MAIN_THRUST, ph_main,ISP_P0, ISP); - th_main[1] = CreateThruster (_V( 1.7598,0,-13.8705), _V(0,0,1), MAX_MAIN_THRUST, ph_main, ISP_P0, ISP); + th_main[0] = CreateThruster ({-1.7598,0,-13.8705}, {0,0,1}, MAX_MAIN_THRUST, ph_main,ISP_P0, ISP); + th_main[1] = CreateThruster ({ 1.7598,0,-13.8705}, {0,0,1}, MAX_MAIN_THRUST, ph_main, ISP_P0, ISP); thg_main = CreateThrusterGroup (th_main, 2, THGROUP_MAIN); AddExhaust (th_main[0], 12, 2, 2.2); AddExhaust (th_main[1], 12, 2, 2.2); - AddExhaustStream (th_main[0], _V(0,0,-21), &contrail_main); - AddExhaustStream (th_main[0], _V(-1.7598,0,-16.0), &exhaust_main); - AddExhaustStream (th_main[1], _V( 1.7598,0,-16.0), &exhaust_main); + AddExhaustStream (th_main[0], {0,0,-21}, &contrail_main); + AddExhaustStream (th_main[0], {-1.7598,0,-16.0}, &exhaust_main); + AddExhaustStream (th_main[1], { 1.7598,0,-16.0}, &exhaust_main); // hover thrusters - th_hover[0] = CreateThruster (_V(0,-1.49016, 13.0), _V(0,1,0), MAX_HOVER_THRUST, ph_main, ISP_P0, ISP); - th_hover[1] = CreateThruster (_V(0,-1.49016,-13.0), _V(0,1,0), MAX_HOVER_THRUST, ph_main, ISP_P0, ISP); + th_hover[0] = CreateThruster ({0,-1.49016, 13.0}, {0,1,0}, MAX_HOVER_THRUST, ph_main, ISP_P0, ISP); + th_hover[1] = CreateThruster ({0,-1.49016,-13.0}, {0,1,0}, MAX_HOVER_THRUST, ph_main, ISP_P0, ISP); thg_hover = CreateThrusterGroup (th_hover, 2, THGROUP_HOVER); - AddExhaust (th_hover[0], 10, 1, _V(0,-2.265335, 13.608049), _V(0,-1,0)); - AddExhaust (th_hover[1], 10, 1, _V(0,-2.265335,-12.88175), _V(0,-1,0)); - AddExhaustStream (th_hover[0], _V(0,-6, 13.608049), &contrail_hover); - AddExhaustStream (th_hover[1], _V(0,-6,-12.88175), &contrail_hover); - AddExhaustStream (th_hover[0], _V(0,-4, 13.608049), &exhaust_main); - AddExhaustStream (th_hover[1], _V(0,-4,-12.88175), &exhaust_main); + AddExhaust (th_hover[0], 10, 1, {0,-2.265335, 13.608049}, {0,-1,0}); + AddExhaust (th_hover[1], 10, 1, {0,-2.265335,-12.88175}, {0,-1,0}); + AddExhaustStream (th_hover[0], {0,-6, 13.608049}, &contrail_hover); + AddExhaustStream (th_hover[1], {0,-6,-12.88175}, &contrail_hover); + AddExhaustStream (th_hover[0], {0,-4, 13.608049}, &exhaust_main); + AddExhaustStream (th_hover[1], {0,-4,-12.88175}, &exhaust_main); // retro/hover thrusters - th_pod[0] = CreateThruster (_V(-6.97215,0,0), _V(0,0,-1), MAX_RETRO_THRUST, ph_main,ISP_P0, ISP); - th_pod[1] = CreateThruster (_V( 6.97215,0,0), _V(0,0,-1), MAX_RETRO_THRUST, ph_main, ISP_P0, ISP); + th_pod[0] = CreateThruster ({-6.97215,0,0}, {0,0,-1}, MAX_RETRO_THRUST, ph_main,ISP_P0, ISP); + th_pod[1] = CreateThruster ({ 6.97215,0,0}, {0,0,-1}, MAX_RETRO_THRUST, ph_main, ISP_P0, ISP); thg_pod = CreateThrusterGroup (th_pod, 2, THGROUP_USER); AddExhaust (th_pod[0], 6, 1.0, 1.33422); AddExhaust (th_pod[1], 6, 1.0, 1.33422); @@ -1186,78 +1186,78 @@ void ShuttleA::clbkSetClassCaps (FILEHANDLE cfg) // attitude thrusters THRUSTER_HANDLE th_att_rot[4], th_att_lin[4]; - th_att_rot[0] = CreateThruster (_V(-6.01139, 0.61554,0), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[1] = CreateThruster (_V( 6.01139,-0.61554,0), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[2] = CreateThruster (_V(-6.01139,-0.61554,0), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[3] = CreateThruster (_V( 6.01139, 0.61554,0), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[0] = CreateThruster ({-6.01139, 0.61554,0}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[1] = CreateThruster ({ 6.01139,-0.61554,0}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[2] = CreateThruster ({-6.01139,-0.61554,0}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[3] = CreateThruster ({ 6.01139, 0.61554,0}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_BANKLEFT); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_BANKRIGHT); - AddExhaust (th_att_rot[0], 0.7, 0.08, _V(-6.01139, 0.61554,-0.1), _V(0,-1,0)); - AddExhaust (th_att_rot[0], 0.7, 0.08, _V(-6.01139, 0.61554,0.1), _V(0,-1,0)); - AddExhaust (th_att_rot[1], 0.7, 0.08, _V( 6.01139,-0.61554,-0.1), _V(0, 1,0)); - AddExhaust (th_att_rot[1], 0.7, 0.08, _V( 6.01139,-0.61554,0.1), _V(0, 1,0)); - AddExhaust (th_att_rot[2], 0.7, 0.08, _V(-6.01139,-0.61554,-0.1), _V(0, 1,0)); - AddExhaust (th_att_rot[2], 0.7, 0.08, _V(-6.01139,-0.61554,0.1), _V(0, 1,0)); - AddExhaust (th_att_rot[3], 0.7, 0.08, _V( 6.01139, 0.61554,-0.1), _V(0,-1,0)); - AddExhaust (th_att_rot[3], 0.7, 0.08, _V( 6.01139, 0.61554,0.1), _V(0,-1,0)); - - th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 15), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[1] = th_att_lin[2] = CreateThruster (_V(0,0,-15), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[2] = th_att_lin[3] = CreateThruster (_V(0,0, 15), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-15), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); + AddExhaust (th_att_rot[0], 0.7, 0.08, {-6.01139, 0.61554,-0.1}, {0,-1,0}); + AddExhaust (th_att_rot[0], 0.7, 0.08, {-6.01139, 0.61554,0.1}, {0,-1,0}); + AddExhaust (th_att_rot[1], 0.7, 0.08, { 6.01139,-0.61554,-0.1}, {0, 1,0}); + AddExhaust (th_att_rot[1], 0.7, 0.08, { 6.01139,-0.61554,0.1}, {0, 1,0}); + AddExhaust (th_att_rot[2], 0.7, 0.08, {-6.01139,-0.61554,-0.1}, {0, 1,0}); + AddExhaust (th_att_rot[2], 0.7, 0.08, {-6.01139,-0.61554,0.1}, {0, 1,0}); + AddExhaust (th_att_rot[3], 0.7, 0.08, { 6.01139, 0.61554,-0.1}, {0,-1,0}); + AddExhaust (th_att_rot[3], 0.7, 0.08, { 6.01139, 0.61554,0.1}, {0,-1,0}); + + th_att_rot[0] = th_att_lin[0] = CreateThruster ({0,0, 15}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[1] = th_att_lin[2] = CreateThruster ({0,0,-15}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[2] = th_att_lin[3] = CreateThruster ({0,0, 15}, {0,-1,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[3] = th_att_lin[1] = CreateThruster ({0,0,-15}, {0, 1,0}, MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_PITCHUP); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_PITCHDOWN); CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_UP); CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_DOWN); - AddExhaust (th_att_rot[0], 0.7, 0.08, _V(-0.13,-0.9,17.95), _V(0,-1,0)); - AddExhaust (th_att_rot[0], 0.7, 0.08, _V( 0.13,-0.9,17.95), _V(0,-1,0)); - AddExhaust (th_att_rot[1], 0.7, 0.08, _V( 0, 2.25,-14.0), _V(0, 1,0)); - AddExhaust (th_att_rot[1], 0.7, 0.08, _V( 0, 2.25,-14.23), _V(0, 1,0)); - AddExhaust (th_att_rot[2], 0.7, 0.08, _V(-0.13, 2.03, 17.9), _V(0, 1,0)); - AddExhaust (th_att_rot[2], 0.7, 0.08, _V( 0.13, 2.03, 17.9), _V(0, 1,0)); - AddExhaust (th_att_rot[3], 0.7, 0.08, _V(-0.13,-1.76,-14.1), _V(0,-1,0)); - AddExhaust (th_att_rot[3], 0.7, 0.08, _V( 0.13,-1.76,-14.1), _V(0,-1,0)); - - th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 15), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[1] = th_att_lin[2] = CreateThruster (_V(0,0,-15), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[2] = th_att_lin[3] = CreateThruster (_V(0,0, 15), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); - th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-15), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); + AddExhaust (th_att_rot[0], 0.7, 0.08, {-0.13,-0.9,17.95}, {0,-1,0}); + AddExhaust (th_att_rot[0], 0.7, 0.08, { 0.13,-0.9,17.95}, {0,-1,0}); + AddExhaust (th_att_rot[1], 0.7, 0.08, { 0, 2.25,-14.0}, {0, 1,0}); + AddExhaust (th_att_rot[1], 0.7, 0.08, { 0, 2.25,-14.23}, {0, 1,0}); + AddExhaust (th_att_rot[2], 0.7, 0.08, {-0.13, 2.03, 17.9}, {0, 1,0}); + AddExhaust (th_att_rot[2], 0.7, 0.08, { 0.13, 2.03, 17.9}, {0, 1,0}); + AddExhaust (th_att_rot[3], 0.7, 0.08, {-0.13,-1.76,-14.1}, {0,-1,0}); + AddExhaust (th_att_rot[3], 0.7, 0.08, { 0.13,-1.76,-14.1}, {0,-1,0}); + + th_att_rot[0] = th_att_lin[0] = CreateThruster ({0,0, 15}, { 1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[1] = th_att_lin[2] = CreateThruster ({0,0,-15}, {-1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[2] = th_att_lin[3] = CreateThruster ({0,0, 15}, {-1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); + th_att_rot[3] = th_att_lin[1] = CreateThruster ({0,0,-15}, { 1,0,0}, MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_YAWRIGHT); CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_YAWLEFT); CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_RIGHT); CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_LEFT); - AddExhaust (th_att_rot[0], 0.7, 0.08, _V(-2.18, 0.13, 17.87), _V(-1,0,0)); - AddExhaust (th_att_rot[0], 0.7, 0.08, _V(-2.18,-0.13, 17.87), _V(-1,0,0)); - AddExhaust (th_att_rot[1], 0.7, 0.08, _V( 3.347, 0, -14.24), _V( 1,0,0)); - AddExhaust (th_att_rot[1], 0.7, 0.08, _V( 3.347, 0, -14.03), _V( 1,0,0)); - AddExhaust (th_att_rot[2], 0.7, 0.08, _V( 2.18, 0.13, 17.87), _V( 1,0,0)); - AddExhaust (th_att_rot[2], 0.7, 0.08, _V( 2.18,-0.13, 17.87), _V( 1,0,0)); - AddExhaust (th_att_rot[3], 0.7, 0.08, _V(-3.347, 0, -14.24), _V(-1,0,0)); - AddExhaust (th_att_rot[3], 0.7, 0.08, _V(-3.347, 0, -14.03), _V(-1,0,0)); - - th_att_lin[0] = CreateThruster (_V( 0,0,0), _V(0,0, 1), 2*MAX_RCS_THRUST, ph_rcs, ISP); - th_att_lin[1] = CreateThruster (_V( 0,0,0), _V(0,0,-1), 2*MAX_RCS_THRUST, ph_rcs, ISP); + AddExhaust (th_att_rot[0], 0.7, 0.08, {-2.18, 0.13, 17.87}, {-1,0,0}); + AddExhaust (th_att_rot[0], 0.7, 0.08, {-2.18,-0.13, 17.87}, {-1,0,0}); + AddExhaust (th_att_rot[1], 0.7, 0.08, { 3.347, 0, -14.24}, { 1,0,0}); + AddExhaust (th_att_rot[1], 0.7, 0.08, { 3.347, 0, -14.03}, { 1,0,0}); + AddExhaust (th_att_rot[2], 0.7, 0.08, { 2.18, 0.13, 17.87}, { 1,0,0}); + AddExhaust (th_att_rot[2], 0.7, 0.08, { 2.18,-0.13, 17.87}, { 1,0,0}); + AddExhaust (th_att_rot[3], 0.7, 0.08, {-3.347, 0, -14.24}, {-1,0,0}); + AddExhaust (th_att_rot[3], 0.7, 0.08, {-3.347, 0, -14.03}, {-1,0,0}); + + th_att_lin[0] = CreateThruster ({ 0,0,0}, {0,0, 1}, 2*MAX_RCS_THRUST, ph_rcs, ISP); + th_att_lin[1] = CreateThruster ({ 0,0,0}, {0,0,-1}, 2*MAX_RCS_THRUST, ph_rcs, ISP); CreateThrusterGroup (th_att_lin, 1, THGROUP_ATT_FORWARD); CreateThrusterGroup (th_att_lin+1, 1, THGROUP_ATT_BACK); - AddExhaust (th_att_lin[0], 0.7, 0.15, _V( 6.01139,0,-1.16102), _V(0,0,-1)); - AddExhaust (th_att_lin[0], 0.7, 0.15, _V(-6.01139,0,-1.16102), _V(0,0,-1)); - AddExhaust (th_att_lin[1], 0.7, 0.15, _V( 6.01139,0, 1.16102), _V(0,0, 1)); - AddExhaust (th_att_lin[1], 0.7, 0.15, _V(-6.01139,0, 1.16102), _V(0,0, 1)); + AddExhaust (th_att_lin[0], 0.7, 0.15, { 6.01139,0,-1.16102}, {0,0,-1}); + AddExhaust (th_att_lin[0], 0.7, 0.15, {-6.01139,0,-1.16102}, {0,0,-1}); + AddExhaust (th_att_lin[1], 0.7, 0.15, { 6.01139,0, 1.16102}, {0,0, 1}); + AddExhaust (th_att_lin[1], 0.7, 0.15, {-6.01139,0, 1.16102}, {0,0, 1}); // ************************ Attachment points **************************** char attach_id[8]={"SH"}; - payload_attachment[0] = CreateAttachment (false,_V(1.76f,0.0f, 6.28f),_V(0.0f,0.0f,-1.0f),_V(0.0f,1.0f,0.0f),attach_id); - payload_attachment[1] = CreateAttachment (false,_V(1.76f,0.0f,-1.28f),_V(0.0f,0.0f,-1.0f),_V(0.0f,1.0f,0.0f),attach_id); - payload_attachment[2] = CreateAttachment (false,_V(1.76f,0.0f,-6.600f),_V(0.0f,0.0f,-1.0f),_V(0.0f,1.0f,0.0f),attach_id); + payload_attachment[0] = CreateAttachment (false,{1.76f,0.0f, 6.28f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},attach_id); + payload_attachment[1] = CreateAttachment (false,{1.76f,0.0f,-1.28f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},attach_id); + payload_attachment[2] = CreateAttachment (false,{1.76f,0.0f,-6.600f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},attach_id); - payload_attachment[3] = CreateAttachment (false,_V(-1.76f,0.0f, 6.28f),_V(0.0f,0.0f,-1.0f),_V(0.0f,1.0f,0.0f),attach_id); - payload_attachment[4] = CreateAttachment (false,_V(-1.76f,0.0f,-1.28f),_V(0.0f,0.0f,-1.0f),_V(0.0f,1.0f,0.0f),attach_id); - payload_attachment[5] = CreateAttachment (false,_V(-1.76f,0.0f,-6.600f),_V(0.0f,0.0f,-1.0f),_V(0.0f,1.0f,0.0f),attach_id); + payload_attachment[3] = CreateAttachment (false,{-1.76f,0.0f, 6.28f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},attach_id); + payload_attachment[4] = CreateAttachment (false,{-1.76f,0.0f,-1.28f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},attach_id); + payload_attachment[5] = CreateAttachment (false,{-1.76f,0.0f,-6.600f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},attach_id); // ************************ Airfoil **************************** ClearAirfoilDefinitions(); - CreateAirfoil (LIFT_VERTICAL, _V(0,0,0), Shuttle_MomentCoeff, 8, 140, 0.1); + CreateAirfoil (LIFT_VERTICAL, {0,0,0}, Shuttle_MomentCoeff, 8, 140, 0.1); // ************************ Meshes **************************** @@ -1454,7 +1454,7 @@ void ShuttleA::clbkPostCreation () pod_angle_request[i] = pod_angle[i]; double sina = sin(pod_angle[i]), cosa = cos(pod_angle[i]); SetAnimation (anim_pod[i], pod_angle[i]/PI); - SetThrusterDir (th_pod[i], _V(0,sina,-cosa)); + SetThrusterDir (th_pod[i], {0,sina,-cosa}); } SetAnimation (anim_dock, dock_proc); for (i = 0; i < 2; i++) @@ -1488,7 +1488,7 @@ void ShuttleA::clbkPostStep (double simt, double simdt, double mjd) pod_angle[i] = pod_angle_request[i]; } double sina = sin(pod_angle[i]), cosa = cos(pod_angle[i]); - SetThrusterDir (th_pod[i], _V(0,sina,-cosa)); + SetThrusterDir (th_pod[i], {0,sina,-cosa}); SetAnimation (anim_pod[i], pod_angle[i]/PI); redraw = true; } @@ -1621,14 +1621,14 @@ bool ShuttleA::clbkLoadPanel2D (int id, PANELHANDLE hPanel, DWORD viewW, DWORD v DefineMainPanel (hPanel); ScalePanel (hPanel, viewW, viewH); oapiSetPanelNeighbours (-1,-1,1,-1); - SetCameraDefaultDirection (_V(0,0,1)); // forward + SetCameraDefaultDirection ({0,0,1}); // forward oapiCameraSetCockpitDir (0,0); // look forward return true; case 1: DefineOverheadPanel (hPanel); ScalePanel (hPanel, viewW, viewH); oapiSetPanelNeighbours (-1,-1,-1,0); - SetCameraDefaultDirection (_V(0,0,1)); // forward + SetCameraDefaultDirection ({0,0,1}); // forward oapiCameraSetCockpitDir (0,20*RAD); // look up return true; default: @@ -2030,24 +2030,24 @@ bool ShuttleA::clbkLoadVC (int id) oapiVCRegisterArea (AID_ENGINEPODLEVEL, PANEL_REDRAW_ALWAYS, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED); oapiVCSetAreaClickmode_Quadrilateral (AID_ENGINEPODLEVEL, - _V(-0.662748635f,2.000830898f,16.28952821f), - _V(-0.637967796f,2.001747096f,16.2875631f), - _V(-0.662748635f,1.951983908f,16.26675439f), - _V(-0.637967796f,1.952900106f,16.26478928f)); + {-0.662748635f,2.000830898f,16.28952821f}, + {-0.637967796f,2.001747096f,16.2875631f}, + {-0.662748635f,1.951983908f,16.26675439f}, + {-0.637967796f,1.952900106f,16.26478928f}); oapiVCRegisterArea (AID_ENGINEHOVER, PANEL_REDRAW_ALWAYS, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED); oapiVCSetAreaClickmode_Quadrilateral (AID_ENGINEHOVER, - _V(-0.610236858f,2.113885847f,16.33716825f), - _V(-0.584865999f,2.114823859f,16.33515635f), - _V(-0.610236858f,2.017265428f,16.29212113f), - _V(-0.584865999f,2.01820344f,16.29010923f)); + {-0.610236858f,2.113885847f,16.33716825f}, + {-0.584865999f,2.114823859f,16.33515635f}, + {-0.610236858f,2.017265428f,16.29212113f}, + {-0.584865999f,2.01820344f,16.29010923f}); oapiVCRegisterArea (AID_ENGINEMAIN, PANEL_REDRAW_ALWAYS, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED); oapiVCSetAreaClickmode_Quadrilateral (AID_ENGINEMAIN, - _V(-0.662158615f,2.111966194f,16.34128561f), - _V(-0.637377776f,2.112882392f,16.3393205f), - _V(-0.662158615f,2.015345775f,16.29623849f), - _V(-0.637377776f,2.016261973f,16.29427338f)); + {-0.662158615f,2.111966194f,16.34128561f}, + {-0.637377776f,2.112882392f,16.3393205f}, + {-0.662158615f,2.015345775f,16.29623849f}, + {-0.637377776f,2.016261973f,16.29427338f}); SURFHANDLE tex1 = oapiGetTextureHandle (vcmesh_tpl,10); //engine thrust tex oapiVCRegisterArea (AID_ENGINEINDICATOR, _R( 4,4, 129,194), PANEL_REDRAW_ALWAYS, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex1); @@ -2058,76 +2058,76 @@ bool ShuttleA::clbkLoadVC (int id) tex1 = oapiGetTextureHandle (vcmesh_tpl,12); //navmode tex oapiVCRegisterArea (AID_NAVMODE, _R( 0,0, 262,32), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral (AID_NAVMODE, - _V(-0.843884764f,2.123497933f,16.36420527f), - _V(-0.689299533f,2.129213263f,16.35194677f), - _V(-0.843884764f,2.106857749f,16.35644716f), - _V(-0.689299533f,2.112573079f,16.34418865f)); + {-0.843884764f,2.123497933f,16.36420527f}, + {-0.689299533f,2.129213263f,16.35194677f}, + {-0.843884764f,2.106857749f,16.35644716f}, + {-0.689299533f,2.112573079f,16.34418865f}); oapiVCRegisterArea (AID_PODANGLEPRESET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN); oapiVCSetAreaClickmode_Quadrilateral (AID_PODANGLEPRESET, - _V(-0.553004921f,2.007572246f,16.28207691f), - _V(-0.528224082f,2.008488444f,16.28011181f), - _V(-0.553004921f,1.980733241f,16.26956382f), - _V(-0.528224082f,1.981649439f,16.26759872f)); + {-0.553004921f,2.007572246f,16.28207691f}, + {-0.528224082f,2.008488444f,16.28011181f}, + {-0.553004921f,1.980733241f,16.26956382f}, + {-0.528224082f,1.981649439f,16.26759872f}); oapiVCRegisterArea (AID_PODANGLESWITCH, PANEL_REDRAW_MOUSE, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_LBUP); oapiVCSetAreaClickmode_Quadrilateral (AID_PODANGLESWITCH, - _V(-0.602566598f,2.000372049f,16.2835045f), - _V(-0.5730656f,2.001462761f,16.28116509f), - _V(-0.602566598f,1.976753725f,16.27249298f), - _V(-0.5730656f,1.977844437f,16.27015357f)); + {-0.602566598f,2.000372049f,16.2835045f}, + {-0.5730656f,2.001462761f,16.28116509f}, + {-0.602566598f,1.976753725f,16.27249298f}, + {-0.5730656f,1.977844437f,16.27015357f}); oapiVCRegisterArea (AID_ATTITUDEMODE, PANEL_REDRAW_MOUSE, PANEL_MOUSE_LBDOWN); oapiVCSetAreaClickmode_Quadrilateral (AID_ATTITUDEMODE, - _V(-0.485742645f,2.112584069f,16.32454306f), - _V(-0.473942246f,2.113020354f,16.32360729f), - _V(-0.485742645f,2.088965745f,16.31353154f), - _V(-0.473942246f,2.089402029f,16.31259578f)); + {-0.485742645f,2.112584069f,16.32454306f}, + {-0.473942246f,2.113020354f,16.32360729f}, + {-0.485742645f,2.088965745f,16.31353154f}, + {-0.473942246f,2.089402029f,16.31259578f}); // MFD1 buttons tex1 = oapiGetTextureHandle (vcmesh_tpl,13); //mfd buttons tex oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS, - _V(-0.873975f, 2.07783f, 16.3458f), - _V(-0.898166f, 2.07693f, 16.3477f), - _V(-0.873975f, 1.95705f, 16.2895f), - _V(-0.898166f, 1.95616f, 16.2914f)); + {-0.873975f, 2.07783f, 16.3458f}, + {-0.898166f, 2.07693f, 16.3477f}, + {-0.873975f, 1.95705f, 16.2895f}, + {-0.898166f, 1.95616f, 16.2914f}); oapiVCRegisterArea (AID_MFD1_RBUTTONS, _R( 49,9, 73,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_RBUTTONS, - _V(-0.691069f, 2.08459f, 16.3313f), - _V(-0.715260f, 2.08459f, 16.3313f), - _V(-0.691069f, 1.96381f, 16.2750f), - _V(-0.715260f, 1.96381f, 16.2750f)); + {-0.691069f, 2.08459f, 16.3313f}, + {-0.715260f, 2.08459f, 16.3313f}, + {-0.691069f, 1.96381f, 16.2750f}, + {-0.715260f, 1.96381f, 16.2750f}); oapiVCRegisterArea (AID_MFD1_BBUTTONS,PANEL_REDRAW_NEVER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_BBUTTONS, - _V(-0.833854424f,1.94565778f,16.28032296f), - _V(-0.755381769f,1.948559073f,16.27410013f), - _V(-0.833854424f,1.935458958f,16.27556799f), - _V(-0.755381769f,1.938360251f,16.26934516f)); + {-0.833854424f,1.94565778f,16.28032296f}, + {-0.755381769f,1.948559073f,16.27410013f}, + {-0.833854424f,1.935458958f,16.27556799f}, + {-0.755381769f,1.938360251f,16.26934516f}); //MFD2 buttons oapiVCRegisterArea (AID_MFD2_LBUTTONS, _R(90 ,9,114,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD2_LBUTTONS, - _V(-0.424380f, 2.09445f, 16.3101f), - _V(-0.448571f, 2.09356f, 16.3120f), - _V(-0.424380f, 1.97367f, 16.2538f), - _V(-0.448571f, 1.97278f, 16.2557f)); + {-0.424380f, 2.09445f, 16.3101f}, + {-0.448571f, 2.09356f, 16.3120f}, + {-0.424380f, 1.97367f, 16.2538f}, + {-0.448571f, 1.97278f, 16.2557f}); oapiVCRegisterArea (AID_MFD2_RBUTTONS, _R( 131,9, 155,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD2_RBUTTONS, - _V(-0.241474f, 2.10121f, 16.2956f), - _V(-0.265665f, 2.10032f, 16.2975f), - _V(-0.241474f, 1.98044f, 16.2393f), - _V(-0.265665f, 1.97954f, 16.2412f)); + {-0.241474f, 2.10121f, 16.2956f}, + {-0.265665f, 2.10032f, 16.2975f}, + {-0.241474f, 1.98044f, 16.2393f}, + {-0.265665f, 1.97954f, 16.2412f}); oapiVCRegisterArea (AID_MFD2_BBUTTONS,PANEL_REDRAW_NEVER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD2_BBUTTONS, - _V(-0.384259211f,2.015958238f,16.26969654f), - _V(-0.305786556f,2.018859532f,16.26347371f), - _V(-0.384259211f,1.952081406f,16.23991538f), - _V(-0.305786556f,1.954982699f,16.23369255f)); + {-0.384259211f,2.015958238f,16.26969654f}, + {-0.305786556f,2.018859532f,16.26347371f}, + {-0.384259211f,1.952081406f,16.23991538f}, + {-0.305786556f,1.954982699f,16.23369255f}); //OVERHEAD Panel @@ -2145,38 +2145,38 @@ bool ShuttleA::clbkLoadVC (int id) oapiVCRegisterArea(AID_DOCKSWITCH,PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN); oapiVCSetAreaClickmode_Quadrilateral(AID_DOCKSWITCH, - _V(-0.227115067f,2.608473414f,16.10024382f), - _V(-0.227115067f,2.609185081f,16.08870423f), - _V(-0.209934233f,2.591621747f,16.09921048f), - _V(-0.209934233f,2.592333414f,16.0876709f)); + {-0.227115067f,2.608473414f,16.10024382f}, + {-0.227115067f,2.609185081f,16.08870423f}, + {-0.209934233f,2.591621747f,16.09921048f}, + {-0.209934233f,2.592333414f,16.0876709f}); oapiVCRegisterArea(AID_AIRLOCK1SWITCH,PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN); oapiVCSetAreaClickmode_Quadrilateral(AID_AIRLOCK1SWITCH, - _V(-0.258040567f,2.638747108f,16.10306545f), - _V(-0.258040567f,2.639458775f,16.09152586f), - _V(-0.240859733f,2.621895442f,16.10203211f), - _V(-0.240859733f,2.622607108f,16.09049253f)); + {-0.258040567f,2.638747108f,16.10306545f}, + {-0.258040567f,2.639458775f,16.09152586f}, + {-0.240859733f,2.621895442f,16.10203211f}, + {-0.240859733f,2.622607108f,16.09049253f}); oapiVCRegisterArea(AID_GEARSWITCH,PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN); oapiVCSetAreaClickmode_Quadrilateral(AID_GEARSWITCH, - _V(-0.227115067f,2.609985706f,16.0757222f), - _V(-0.227115067f,2.610697372f,16.06418262f), - _V(-0.209934233f,2.593134039f,16.07468887f), - _V(-0.209934233f,2.593845706f,16.06314928f)); + {-0.227115067f,2.609985706f,16.0757222f}, + {-0.227115067f,2.610697372f,16.06418262f}, + {-0.209934233f,2.593134039f,16.07468887f}, + {-0.209934233f,2.593845706f,16.06314928f}); tex1 = oapiGetTextureHandle (vcmesh_tpl,16); //cargo tex oapiVCRegisterArea(AID_CARGO_OPEN, _R( 0, 25, 84, 156), PANEL_REDRAW_MOUSE, PANEL_MOUSE_LBDOWN,PANEL_MAP_BACKGROUND,tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_CARGO_OPEN, - _V(-0.250824617f,2.635761492f,16.03627884f), - _V(-0.250824617f,2.638222672f,15.99637112f), - _V(-0.20615445f,2.591947158f,16.03359218f), - _V(-0.20615445f,2.594408339f,15.99368445f)); + {-0.250824617f,2.635761492f,16.03627884f}, + {-0.250824617f,2.638222672f,15.99637112f}, + {-0.20615445f,2.591947158f,16.03359218f}, + {-0.20615445f,2.594408339f,15.99368445f}); oapiVCRegisterArea(AID_GARGOARMSWITCH,PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN); oapiVCSetAreaClickmode_Quadrilateral(AID_GARGOARMSWITCH, - _V(-0.227115067f,2.615708692f,15.98292472f), - _V(-0.227115067f,2.616420358f,15.97138514f), - _V(-0.209934233f,2.598857025f,15.98189139f), - _V(-0.209934233f,2.599568692f,15.9703518f)); + {-0.227115067f,2.615708692f,15.98292472f}, + {-0.227115067f,2.616420358f,15.97138514f}, + {-0.209934233f,2.598857025f,15.98189139f}, + {-0.209934233f,2.599568692f,15.9703518f}); diff --git a/Src/Vessel/ShuttleA/ShuttleA_PL/ShuttleA_pl.cpp b/Src/Vessel/ShuttleA/ShuttleA_PL/ShuttleA_pl.cpp index 8a96a4454..709861dc8 100644 --- a/Src/Vessel/ShuttleA/ShuttleA_PL/ShuttleA_pl.cpp +++ b/Src/Vessel/ShuttleA/ShuttleA_PL/ShuttleA_pl.cpp @@ -88,7 +88,7 @@ void ShuttleA_PL::SetNormalConfig() SetMeshVisibilityMode (AddMesh (mesh_main), MESHVIS_EXTERNAL); ClearAirfoilDefinitions(); - CreateAirfoil (LIFT_VERTICAL, _V(0,-4,4), None_MomentCoeff, 4, 2500, 0.5); + CreateAirfoil (LIFT_VERTICAL, {0,-4,4}, None_MomentCoeff, 4, 2500, 0.5); } void ShuttleA_PL::SetDrogueConfig() @@ -98,7 +98,7 @@ void ShuttleA_PL::SetDrogueConfig() SetMeshVisibilityMode (AddMesh (mesh_drogue), MESHVIS_EXTERNAL); ClearAirfoilDefinitions(); - CreateAirfoil (LIFT_VERTICAL, _V(0.0f,-2.0f,0.0f), Drogue_MomentCoeff, 4, 2500, 0.5); + CreateAirfoil (LIFT_VERTICAL, {0.0f,-2.0f,0.0f}, Drogue_MomentCoeff, 4, 2500, 0.5); } @@ -110,7 +110,7 @@ void ShuttleA_PL::SetParachuteConfig() SetMeshVisibilityMode (AddMesh (mesh_parachute), MESHVIS_EXTERNAL); ClearAirfoilDefinitions(); - CreateAirfoil (LIFT_VERTICAL, _V(0.0f,-2.0f,2.0f), Parachute_MomentCoeff, 4, 2500, 0.5); + CreateAirfoil (LIFT_VERTICAL, {0.0f,-2.0f,2.0f}, Parachute_MomentCoeff, 4, 2500, 0.5); } void ShuttleA_PL::SetPostLandingConfig() @@ -191,18 +191,18 @@ void ShuttleA_PL::clbkSetClassCaps (FILEHANDLE cfg) //Common stuff on all configurations SetSize (5.0); - SetPMI (_V(2.56,2.39,2.02)); + SetPMI ({2.56,2.39,2.02}); SetEmptyMass (20000.0f); - SetCrossSections (_V(17.61f, 17.44f, 13.09f)); - SetRotDrag (_V(0.7, 0.7, 0.3)); + SetCrossSections ({17.61f, 17.44f, 13.09f}); + SetRotDrag ({0.7, 0.7, 0.3}); SetSurfaceFrictionCoeff (0.5, 0.5); - SetCameraOffset (_V(0.0f,0.0f,0.0f)); - SetDockParams (_V(2.00f,0.00f,0.00f), _V(1,0,0), _V(0,1,0)); + SetCameraOffset ({0.0f,0.0f,0.0f}); + SetDockParams ({2.00f,0.00f,0.00f}, {1,0,0}, {0,1,0}); char attach_id[8]={"SH"}; - payload_attachment[0]=CreateAttachment (true,_V(-0.319f, 0.0f, 2.5f),_V(0.0f,0.0f,1.0f),_V(0.0f,1.0f,0.0f),attach_id); - payload_attachment[1]=CreateAttachment (true,_V(-0.319f, 0.0f, -2.5f),_V(0.0f,0.0f,-1.0f),_V(0.0f,1.0f,0.0f),attach_id); - payload_attachment[2]=CreateAttachment (true,_V(-0.319f, 2.0f, 0.0f ),_V(0.0f,1.0f, 0.0f),_V(1.0f,0.0f,0.0f),"GS"); // MS 060906: added by request + payload_attachment[0]=CreateAttachment (true,{-0.319f, 0.0f, 2.5f},{0.0f,0.0f,1.0f},{0.0f,1.0f,0.0f},attach_id); + payload_attachment[1]=CreateAttachment (true,{-0.319f, 0.0f, -2.5f},{0.0f,0.0f,-1.0f},{0.0f,1.0f,0.0f},attach_id); + payload_attachment[2]=CreateAttachment (true,{-0.319f, 2.0f, 0.0f },{0.0f,1.0f, 0.0f},{1.0f,0.0f,0.0f},"GS"); // MS 060906: added by request TOUCHDOWNVTX tdvtx[8] = { {{-2,-2, 2.5}, 2e5, 3e4, 5}, diff --git a/Src/Vessel/ShuttleA/adiball.cpp b/Src/Vessel/ShuttleA/adiball.cpp index ca69398b3..e4e197922 100644 --- a/Src/Vessel/ShuttleA/adiball.cpp +++ b/Src/Vessel/ShuttleA/adiball.cpp @@ -70,8 +70,8 @@ ADIBall::ADIBall (VESSEL3 *v, AttitudeReference *attref): PanelElement (v) rho_curr = tht_curr = phi_curr = 0.0; tgtx_curr = tgty_curr = 0.0; ballvtx0 = 0; - peuler = _V(0,0,0); - vrot = _V(0,0,0); + peuler = {0,0,0}; + vrot = {0,0,0}; euler_t = 0; rate_local = true; } @@ -316,9 +316,9 @@ bool ADIBall::Redraw2D (SURFHANDLE surf) double sint = sin(euler_tgt.y), cost = cos(euler_tgt.y); double sinp = sin(euler_tgt.z), cosp = cos(euler_tgt.z); if (layout == 0) { - tgt = _V(rad*sinp*cost, rad*sint, rad*cosp*cost); + tgt = {rad*sinp*cost, rad*sint, rad*cosp*cost}; } else { - tgt = _V(-rad*sint*cosp, rad*sinp, rad*cost*cosp); + tgt = {-rad*sint*cosp, rad*sinp, rad*cost*cosp}; } tgtx = min(max( (a1*tgt.x + b1*tgt.y + c1*tgt.z), -erange), erange); tgty = min(max(-(a2*tgt.x + b2*tgt.y + c2*tgt.z), -erange), erange); diff --git a/Src/Vessel/ShuttleA/adictrl.cpp b/Src/Vessel/ShuttleA/adictrl.cpp index 481c29c47..c2d792dab 100644 --- a/Src/Vessel/ShuttleA/adictrl.cpp +++ b/Src/Vessel/ShuttleA/adictrl.cpp @@ -280,7 +280,7 @@ void ADICtrl::UpdateDisplay (SURFHANDLE surf, bool force) if (!sh->GetAttref()->GetTgtEulerAngles (ofs)) { tgtmode = 0; - ofs = _V(0,0,0); + ofs = {0,0,0}; } DispAngle (surf, ofs.y, 58, 39, dispprm.tgtdev[0]); DispAngle (surf, ofs.z, 86, 39, dispprm.tgtdev[1]); @@ -393,8 +393,8 @@ bool ADICtrl::ProcessSwitches (int event, int mx, int my) if (mx < 23) { if (mx < 17 && (event & PANEL_MOUSE_LBDOWN)) { - if (settgt) sh->GetAttref()->SetTgtOffset (_V(0,0,0)); - else sh->GetAttref()->SetEulerOffset (_V(0,0,0)); + if (settgt) sh->GetAttref()->SetTgtOffset ({0,0,0}); + else sh->GetAttref()->SetEulerOffset ({0,0,0}); return true; } return false; diff --git a/Src/Vessel/ShuttleA/attref.cpp b/Src/Vessel/ShuttleA/attref.cpp index 5605f3c7a..856e85b4d 100644 --- a/Src/Vessel/ShuttleA/attref.cpp +++ b/Src/Vessel/ShuttleA/attref.cpp @@ -21,10 +21,10 @@ AttitudeReference::AttitudeReference (const VESSEL *vessel) valid_axes = false; valid_euler = false; valid_tgteuler = false; - euler_offs = _V(0,0,0); - tgt_offs = _V(0,0,0); - tgt_rvel = _V(0,0,0); - tgt_ppos = _V(0,0,0); + euler_offs = {0,0,0}; + tgt_offs = {0,0,0}; + tgt_rvel = {0,0,0}; + tgt_ppos = {0,0,0}; tgt_ptime = 0; } @@ -94,15 +94,15 @@ const MATRIX3 &AttitudeReference::GetFrameRotMatrix () const VECTOR3 axis1, axis2, axis3; switch (mode) { case 0: // inertial (ecliptic) - axis3 = _V(1,0,0); - axis2 = _V(0,1,0); + axis3 = {1,0,0}; + axis2 = {0,1,0}; break; case 1: { // inertial (equator) MATRIX3 R; oapiGetPlanetObliquityMatrix (v->GetGravityRef(), &R); - //axis3 = _V(R.m13, R.m23, R.m33); - axis3 = _V(R.m11, R.m21, R.m31); - axis2 = _V(R.m12, R.m22, R.m32); + //axis3 = {R.m13, R.m23, R.m33}; + axis3 = {R.m11, R.m21, R.m31}; + axis2 = {R.m12, R.m22, R.m32}; } break; case 2: { // orbital velocity / orbital momentum vector OBJHANDLE hRef = v->GetGravityRef(); @@ -110,8 +110,8 @@ const MATRIX3 &AttitudeReference::GetFrameRotMatrix () const axis3 = unit (axis3); VECTOR3 vv, vm; v->GetRelativePos (hRef, vv); // local vertical - vm = crossp (axis3,vv); // direction of orbital momentum - axis2 = unit (crossp (vm,axis3)); + vm = cross(axis3, vv); // direction of orbital momentum + axis2 = unit(cross(vm, axis3)); } break; case 3: { // local horizon / local north (surface) OBJHANDLE hRef = v->GetSurfaceRef(); @@ -120,14 +120,14 @@ const MATRIX3 &AttitudeReference::GetFrameRotMatrix () const MATRIX3 prot; oapiGetRotationMatrix (hRef, &prot); VECTOR3 paxis = {prot.m12, prot.m22, prot.m32}; // planet rotation axis in global frame - VECTOR3 yaxis = unit (crossp (paxis,axis2)); // direction of yaw=+90 pole in global frame - axis3 = crossp (axis2,yaxis); + VECTOR3 yaxis = unit(cross(paxis, axis2)); // direction of yaw=+90 pole in global frame + axis3 = cross(axis2, yaxis); } break; case 4: { // synced to NAV source (type-specific) NAVDATA ndata; NAVHANDLE hNav = v->GetNavSource (navid); - axis3 = _V(0,0,1); - axis2 = _V(0,1,0); + axis3 = {0,0,1}; + axis2 = {0,1,0}; if (hNav) { oapiGetNavData (hNav, &ndata); switch (ndata.type) { @@ -149,13 +149,13 @@ const MATRIX3 &AttitudeReference::GetFrameRotMatrix () const axis2 = unit (axis2); oapiGetNavPos (hNav, &npos); npos -= spos; - axis3 = unit(crossp(crossp(axis2,npos),axis2)); + axis3 = unit(cross(cross(axis2, npos), axis2)); } break; } } } break; } - axis1 = crossp(axis2,axis3); + axis1 = cross(axis2, axis3); R = _M(axis1.x, axis2.x, axis3.x, axis1.y, axis2.y, axis3.y, axis1.z, axis2.z, axis3.z); valid_axes = true; @@ -284,7 +284,7 @@ void AttitudeReference::PostStep (double simt, double simdt, double mjd) MATRIX3 Rp; oapiGetRotationMatrix (hObj, &Rp); oapiGetGlobalVel (hObj, &tvel); - tvel += mul (Rp, _V(-sin(data.vor.lng),0,cos(data.vor.lng)) * PI2/oapiGetPlanetPeriod(hObj)*oapiGetSize(hObj)*cos(data.vor.lat)); + tvel += mul(Rp, VECTOR3{-std::sin(data.vor.lng), 0, std::cos(data.vor.lng)} * PI2 / oapiGetPlanetPeriod(hObj) * oapiGetSize(hObj) * std::cos(data.vor.lat)); tgt_rvel = svel-tvel; sprintf (oapiDebugString(), "rvel: x=%f, y=%f, z=%f", tgt_rvel.x, tgt_rvel.y, tgt_rvel.z); } return; // done diff --git a/Src/Vessel/ShuttlePB/ShuttlePB.cpp b/Src/Vessel/ShuttlePB/ShuttlePB.cpp index f2133412f..f34f6b5e4 100644 --- a/Src/Vessel/ShuttlePB/ShuttlePB.cpp +++ b/Src/Vessel/ShuttlePB/ShuttlePB.cpp @@ -49,18 +49,18 @@ const VECTOR3 PB_DOCK_ROT = {0,0,-1}; // docking port alignment directi // Define impact convex hull static const DWORD ntdvtx = 12; static TOUCHDOWNVTX tdvtx[ntdvtx] = { - {_V( 0, -1.5, 2 ), 2e4, 1e3, 1.6, 1}, - {_V(-1, -1.5,-1.5), 2e4, 1e3, 3.0, 1}, - {_V( 1, -1.5,-1.5), 2e4, 1e3, 3.0, 1}, - {_V(-0.5,-0.75,3 ), 2e4, 1e3, 3.0}, - {_V( 0.5,-0.75,3 ), 2e4, 1e3, 3.0}, - {_V(-2.6,-1.1,-1.9), 2e4, 1e3, 3.0}, - {_V( 2.6,-1.1,-1.9), 2e4, 1e3, 3.0}, - {_V(-1, 1.3, 0 ), 2e4, 1e3, 3.0}, - {_V( 1, 1.3, 0 ), 2e4, 1e3, 3.0}, - {_V(-1, 1.3,-2 ), 2e4, 1e3, 3.0}, - {_V( 1, 1.3,-2 ), 2e4, 1e3, 3.0}, - {_V( 0, 0.3,-3.8), 2e4, 1e3, 3.0} + {{ 0, -1.5, 2 }, 2e4, 1e3, 1.6, 1}, + {{-1, -1.5,-1.5}, 2e4, 1e3, 3.0, 1}, + {{ 1, -1.5,-1.5}, 2e4, 1e3, 3.0, 1}, + {{-0.5,-0.75,3 }, 2e4, 1e3, 3.0}, + {{ 0.5,-0.75,3 }, 2e4, 1e3, 3.0}, + {{-2.6,-1.1,-1.9}, 2e4, 1e3, 3.0}, + {{ 2.6,-1.1,-1.9}, 2e4, 1e3, 3.0}, + {{-1, 1.3, 0 }, 2e4, 1e3, 3.0}, + {{ 1, 1.3, 0 }, 2e4, 1e3, 3.0}, + {{-1, 1.3,-2 }, 2e4, 1e3, 3.0}, + {{ 1, 1.3,-2 }, 2e4, 1e3, 3.0}, + {{ 0, 0.3,-3.8}, 2e4, 1e3, 3.0} }; // Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi @@ -160,17 +160,17 @@ void ShuttlePB::clbkSetClassCaps (FILEHANDLE cfg) AddAnimationComponent (anim_elevator, 0, 1, &trans_Relevator); // aerodynamic control surface defintions - CreateControlSurface (AIRCTRL_ELEVATOR, 1.5, 0.7, _V( 0,0,-2.5), AIRCTRL_AXIS_XPOS, anim_elevator); - CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V( 1,0,-2.5), AIRCTRL_AXIS_XPOS, anim_Laileron); - CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V(-1,0,-2.5), AIRCTRL_AXIS_XNEG, anim_Raileron); + CreateControlSurface (AIRCTRL_ELEVATOR, 1.5, 0.7, { 0,0,-2.5}, AIRCTRL_AXIS_XPOS, anim_elevator); + CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, { 1,0,-2.5}, AIRCTRL_AXIS_XPOS, anim_Laileron); + CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, {-1,0,-2.5}, AIRCTRL_AXIS_XNEG, anim_Raileron); // propellant resources PROPELLANT_HANDLE hpr = CreatePropellantResource (PB_FUELMASS); // main engine - th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, PB_ISP); + th_main = CreateThruster ({0,0,-4.35}, {0,0,1}, PB_MAXMAINTH, hpr, PB_ISP); CreateThrusterGroup (&th_main, 1, THGROUP_MAIN); - AddExhaust (th_main, 8, 1, _V(0,0.3,-4.35), _V(0,0,-1)); + AddExhaust (th_main, 8, 1, {0,0.3,-4.35}, {0,0,-1}); PARTICLESTREAMSPEC contrail_main = { 0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE, @@ -182,14 +182,14 @@ void ShuttlePB::clbkSetClassCaps (FILEHANDLE cfg) PARTICLESTREAMSPEC::LVL_SQRT, 0, 1, PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1 }; - AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main); - AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main); + AddExhaustStream (th_main, {0,0.3,-10}, &contrail_main); + AddExhaustStream (th_main, {0,0.3,-5}, &exhaust_main); // hover engine - th_hover = CreateThruster (_V(0,-1.5,0), _V(0,1,0), PB_MAXHOVERTH, hpr, PB_ISP); + th_hover = CreateThruster ({0,-1.5,0}, {0,1,0}, PB_MAXHOVERTH, hpr, PB_ISP); CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER); - AddExhaust (th_hover, 8, 1, _V(0,-1.5,1), _V(0,-1,0)); - AddExhaust (th_hover, 8, 1, _V(0,-1.5,-1), _V(0,-1,0)); + AddExhaust (th_hover, 8, 1, {0,-1.5,1}, {0,-1,0}); + AddExhaust (th_hover, 8, 1, {0,-1.5,-1}, {0,-1,0}); PARTICLESTREAMSPEC contrail_hover = { 0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE, @@ -202,26 +202,26 @@ void ShuttlePB::clbkSetClassCaps (FILEHANDLE cfg) PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1 }; - AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover); - AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover); - AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover); - AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover); + AddExhaustStream (th_hover, {0,-3, 1}, &contrail_hover); + AddExhaustStream (th_hover, {0,-3,-1}, &contrail_hover); + AddExhaustStream (th_hover, {0,-2, 1}, &exhaust_hover); + AddExhaustStream (th_hover, {0,-2,-1}, &exhaust_hover); // RCS engines - th_rcs[ 0] = CreateThruster (_V( 1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[11] = CreateThruster (_V(-1,0,-3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0, 1), PB_MAXRCSTH, hpr, PB_ISP); - th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 0] = CreateThruster ({ 1,0, 3}, {0, 1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 1] = CreateThruster ({ 1,0, 3}, {0,-1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 2] = CreateThruster ({-1,0, 3}, {0, 1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 3] = CreateThruster ({-1,0, 3}, {0,-1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 4] = CreateThruster ({ 1,0,-3}, {0, 1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 5] = CreateThruster ({ 1,0,-3}, {0,-1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 6] = CreateThruster ({-1,0,-3}, {0, 1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 7] = CreateThruster ({-1,0,-3}, {0,-1,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 8] = CreateThruster ({ 1,0, 3}, {-1,0,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[ 9] = CreateThruster ({-1,0, 3}, { 1,0,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[10] = CreateThruster ({ 1,0,-3}, {-1,0,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[11] = CreateThruster ({-1,0,-3}, { 1,0,0}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[12] = CreateThruster ({ 0,0,-3}, {0,0, 1}, PB_MAXRCSTH, hpr, PB_ISP); + th_rcs[13] = CreateThruster ({ 0,0, 3}, {0,0,-1}, PB_MAXRCSTH, hpr, PB_ISP); th_group[0] = th_rcs[0]; th_group[1] = th_rcs[2]; @@ -279,7 +279,7 @@ void ShuttlePB::clbkSetClassCaps (FILEHANDLE cfg) CreateThrusterGroup (th_rcs+13, 1, THGROUP_ATT_BACK); // camera parameters - SetCameraOffset (_V(0,0.8,0)); + SetCameraOffset ({0,0.8,0}); // associate a mesh for the visual AddMesh ("ShuttlePB"); diff --git a/Src/Vessel/Solarsail/Solarsail.cpp b/Src/Vessel/Solarsail/Solarsail.cpp index 016161bf4..9746b182c 100644 --- a/Src/Vessel/Solarsail/Solarsail.cpp +++ b/Src/Vessel/Solarsail/Solarsail.cpp @@ -50,12 +50,12 @@ inline VECTOR3 Nml (const NTVERTEX *v1, const NTVERTEX *v2, const NTVERTEX *v3) float dy1 = v2->y - v1->y, dy2 = v3->y - v1->y; float dz1 = v2->z - v1->z, dz2 = v3->z - v1->z; - return _V(dy1*dz2 - dy2*dz1, dz1*dx2 - dz2*dx1, dx1*dy2 - dx2*dy1); + return {dy1*dz2 - dy2*dz1, dz1*dx2 - dz2*dx1, dx1*dy2 - dx2*dy1}; } inline VECTOR3 crossp (const NTVERTEX *v1, const NTVERTEX *v2) { - return _V(v1->y*v2->z - v2->y*v1->z, v1->z*v2->x - v2->z*v1->x, v1->x*v2->y - v2->x*v1->y); + return {v1->y*v2->z - v2->y*v1->z, v1->z*v2->x - v2->z*v1->x, v1->x*v2->y - v2->x*v1->y}; } // -------------------------------------------------------------- @@ -124,7 +124,7 @@ SolarSail::SolarSail (OBJHANDLE hVessel, int flightmodel) int i; hMesh = NULL; - mf = _V(0,0,0); + mf = {0,0,0}; DefineAnimations(); for (i = 0; i < 4; i++) paddle_rot[i] = paddle_vis[i] = 0.5; @@ -140,10 +140,10 @@ void SolarSail::DefineAnimations () // Steering paddle animations static UINT PaddleGrp[4] = {GRP_paddle1, GRP_paddle2, GRP_paddle3, GRP_paddle4}; - static MGROUP_ROTATE Paddle0 (0, PaddleGrp+0, 1, _V(0,0,0), _V(0,1,0), (float)(180.0*RAD)); - static MGROUP_ROTATE Paddle1 (0, PaddleGrp+1, 1, _V(0,0,0), _V(1,0,0), (float)(180.0*RAD)); - static MGROUP_ROTATE Paddle2 (0, PaddleGrp+2, 1, _V(0,0,0), _V(0,1,0), (float)(180.0*RAD)); - static MGROUP_ROTATE Paddle3 (0, PaddleGrp+3, 1, _V(0,0,0), _V(1,0,0), (float)(180.0*RAD)); + static MGROUP_ROTATE Paddle0 (0, PaddleGrp+0, 1, {0,0,0}, {0,1,0}, (float)(180.0*RAD)); + static MGROUP_ROTATE Paddle1 (0, PaddleGrp+1, 1, {0,0,0}, {1,0,0}, (float)(180.0*RAD)); + static MGROUP_ROTATE Paddle2 (0, PaddleGrp+2, 1, {0,0,0}, {0,1,0}, (float)(180.0*RAD)); + static MGROUP_ROTATE Paddle3 (0, PaddleGrp+3, 1, {0,0,0}, {1,0,0}, (float)(180.0*RAD)); static MGROUP_ROTATE *Paddle[4] = {&Paddle0, &Paddle1, &Paddle2, &Paddle3}; for (i = 0; i < 4; i++) { @@ -175,11 +175,11 @@ void SolarSail::UpdateSail (const VECTOR3 *rpressure) MESHGROUP *sail = oapiMeshGroup (hMesh, sailidx); for (i = 0; i < sail_nvtx; i++) { - F = _V(0,0,rpressure->z*pscale); // note - should be calculated for LOCAL normal + F = {0,0,rpressure->z*pscale}; // note - should be calculated for LOCAL normal vi = sail->Vtx+i; nb = nbhr+i; if (nb->fix) { - sail_vbuf[i] = _V(0,0,0); + sail_vbuf[i] = {0,0,0}; continue; } for (j = 0; j < nb->nnd; j++) { @@ -187,7 +187,7 @@ void SolarSail::UpdateSail (const VECTOR3 *rpressure) dv.x = vj->x - vi->x; dv.y = vj->y - vi->y; dv.z = vj->z - vi->z; - dst = length(dv); + dst = len(dv); if (dst > nb->dst0[j]) { // is stretched F += dv*(elast/nb->dst0[j]); } @@ -255,18 +255,18 @@ void SolarSail::clbkSetClassCaps (FILEHANDLE cfg) SetCW (0.3, 0.3, 0.6, 0.9); SetWingAspect (0.7); SetWingEffectiveness (2.5); - SetCrossSections (_V(10.5,15.0,5.8)); - SetRotDrag (_V(0.6,0.6,0.35)); + SetCrossSections ({10.5,15.0,5.8}); + SetRotDrag ({0.6,0.6,0.35}); if (GetFlightModel() >= 1) { SetPitchMomentScale (1e-4); SetYawMomentScale (1e-4); } - SetPMI (_V(3e3,3e3,6e3)); + SetPMI ({3e3,3e3,6e3}); SetTrimScale (0.05); - SetCameraOffset (_V(0,0.8,0)); + SetCameraOffset ({0,0.8,0}); SetLiftCoeffFunc (LiftCoeff); - SetDockParams (_V(0,1.3,-1), _V(0,1,0), _V(0,0,-1)); - SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5)); + SetDockParams ({0,1.3,-1}, {0,1,0}, {0,0,-1}); + SetTouchdownPoints ({0,-1.5,2}, {-1,-1.5,-1.5}, {1,-1.5,-1.5}); // visual specs AddMesh (hMeshTpl); @@ -282,15 +282,15 @@ void SolarSail::clbkPreStep (double simt, double simdt, double mjd) const double paddle_area = 7812.5; const double albedo = 2.0; static VECTOR3 ppos[4] = { - _V(0,-550,0), _V(-550,0,0), _V(0,550,0), _V(550,0,0) + {0,-550,0}, {-550,0,0}, {0,550,0}, {550,0,0} }; VECTOR3 nml; for (i = 0; i < 4; i++) { double phi = (paddle_rot[i]-0.5)*PI; double sphi = sin(phi), cphi = cos(phi); - if (i%2 == 0) nml = _V(-sphi,0,cphi); - else nml = _V(0,sphi,cphi); - double f = dotp (mf, nml); + if (i%2 == 0) nml = {-sphi,0,cphi}; + else nml = {0,sphi,cphi}; + double f = dot(mf, nml); if (f < 0) { nml = -nml; f = -f; @@ -328,8 +328,8 @@ void SolarSail::clbkGetRadiationForce (const VECTOR3 &mflux, VECTOR3 &F, VECTOR3 // Therefore only the z-component of the radiation momentum flux contributes // to change the sail's momentum (Fresnel reflection) double mom = mflux.z * albedo *area; - F = _V(0,0,mom); - pos = _V(0,0,0); // don't induce torque + F = {0,0,mom}; + pos = {0,0,0}; // don't induce torque } // -------------------------------------------------------------- diff --git a/Utils/meshc/CMakeLists.txt b/Utils/meshc/CMakeLists.txt index 513df770f..e8de2c067 100644 --- a/Utils/meshc/CMakeLists.txt +++ b/Utils/meshc/CMakeLists.txt @@ -8,6 +8,7 @@ add_executable(meshc target_include_directories(meshc PUBLIC ${ORBITER_SOURCE_DIR} + PUBLIC ${ORBITER_SOURCE_SDK_INCLUDE_DIR} ) set_target_properties(meshc