Oolite
Loading...
Searching...
No Matches
OOVector.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Vector
struct  Vector2D

Macros

#define vector_between(a, b)
#define GLVertexOOVector(v)
#define GLTranslateOOVector(v)

Typedefs

typedef struct Vector Vector
typedef struct Vector2D Vector2D

Functions

OOINLINE Vector make_vector (OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
OOINLINE Vector2D MakeVector2D (OOScalar vx, OOScalar vy) INLINE_CONST_FUNC
Vector OORandomUnitVector (void)
Vector OOVectorRandomSpatial (OOScalar maxLength)
Vector OOVectorRandomRadial (OOScalar maxLength)
OOINLINE void scale_vector (Vector *outVector, OOScalar factor) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE Vector vector_multiply_scalar (Vector v, OOScalar s) INLINE_CONST_FUNC
OOINLINE Vector vector_add (Vector a, Vector b) INLINE_CONST_FUNC
OOINLINE Vector vector_subtract (Vector a, Vector b) INLINE_CONST_FUNC
OOINLINE Vector vector_flip (Vector v) INLINE_CONST_FUNC
OOINLINE Vector OOVectorInterpolate (Vector a, Vector b, OOScalar where) INLINE_CONST_FUNC
OOINLINE Vector OOVectorTowards (Vector a, Vector b, OOScalar where) INLINE_CONST_FUNC
OOINLINE bool vector_equal (Vector a, Vector b) INLINE_CONST_FUNC
OOINLINE OOScalar magnitude2 (Vector vec) INLINE_CONST_FUNC
OOINLINE OOScalar magnitude (Vector vec) INLINE_CONST_FUNC
OOINLINE Vector vector_normal (Vector vec) INLINE_CONST_FUNC
OOINLINE Vector vector_normal_or_fallback (Vector vec, Vector fallback) INLINE_CONST_FUNC
OOINLINE Vector vector_normal_or_xbasis (Vector vec) INLINE_CONST_FUNC
OOINLINE Vector vector_normal_or_ybasis (Vector vec) INLINE_CONST_FUNC
OOINLINE Vector vector_normal_or_zbasis (Vector vec) INLINE_CONST_FUNC
OOINLINE OOScalar distance2 (Vector v1, Vector v2) INLINE_CONST_FUNC
OOINLINE OOScalar distance (Vector v1, Vector v2) INLINE_CONST_FUNC
OOINLINE OOScalar dot_product (Vector first, Vector second) INLINE_CONST_FUNC
OOINLINE Vector cross_product (Vector first, Vector second) INLINE_CONST_FUNC
OOINLINE Vector true_cross_product (Vector first, Vector second) CONST_FUNC
OOINLINE OOScalar triple_product (Vector first, Vector second, Vector third) INLINE_CONST_FUNC
OOINLINE Vector normal_to_surface (Vector v1, Vector v2, Vector v3) CONST_FUNC

Variables

const Vector kZeroVector
const Vector kBasisXVector
const Vector kBasisYVector
const Vector kBasisZVector
const Vector2D kZeroVector2D
const Vector2D kBasisXVector2D
const Vector2D kBasisYVector2D

Macro Definition Documentation

◆ GLTranslateOOVector

#define GLTranslateOOVector ( v)
Value:
do { \
Vector v_ = v; \
OOGL(glTranslatef(v_.x, v_.y, v_.z)); \
} while (0)
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

Definition at line 141 of file OOVector.h.

141#define GLTranslateOOVector(v) \
142 do { \
143 Vector v_ = v; \
144 OOGL(glTranslatef(v_.x, v_.y, v_.z)); \
145 } while (0)

◆ GLVertexOOVector

#define GLVertexOOVector ( v)
Value:
do { \
Vector v_ = v; \
glVertex3f(v_.x, v_.y, v_.z); \
} while (0)

Definition at line 136 of file OOVector.h.

136#define GLVertexOOVector(v) \
137 do { \
138 Vector v_ = v; \
139 glVertex3f(v_.x, v_.y, v_.z); \
140 } while (0)

◆ vector_between

#define vector_between ( a,
b )
Value:
OOINLINE Vector vector_subtract(Vector a, Vector b) INLINE_CONST_FUNC
Definition OOVector.h:218

Definition at line 74 of file OOVector.h.

Referenced by ShipEntity::behaviour_tractored:.

Typedef Documentation

◆ Vector

typedef struct Vector Vector

◆ Vector2D

typedef struct Vector2D Vector2D

Function Documentation

◆ cross_product()

OOINLINE Vector cross_product ( Vector first,
Vector second )

Definition at line 294 of file OOVector.h.

295{
296 return vector_normal(true_cross_product(first, second));
297}
OOINLINE Vector true_cross_product(Vector first, Vector second) CONST_FUNC
Definition OOVector.h:285
OOINLINE Vector vector_normal(Vector vec) INLINE_CONST_FUNC
Definition OOVector.h:270

References OOINLINE, true_cross_product(), and vector_normal().

Referenced by ShipEntity::ballTrackLeadingTarget:atTarget:, calculateNormalForTriangle(), OOOpenGLMatrixManager::lookAtWithEye:center:up:, normal_to_surface(), OOMatrixForBillboard(), OOMatrixOrthogonalize(), ShipEntity(PureAI)::setPlanetPatrolCoordinates, and OOExhaustPlumeEntity::update:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ distance()

OOINLINE OOScalar distance ( Vector v1,
Vector v2 )

Definition at line 280 of file OOVector.h.

281{
282 return magnitude(vector_subtract(v1, v2));
283}
OOINLINE OOScalar magnitude(Vector vec) INLINE_CONST_FUNC
Definition OOVector.h:242

References magnitude(), OOINLINE, and vector_subtract().

Referenced by OOVisualEffectEntity(Private)::addSubEntity:, ShipEntity(Private)::addSubentityToCollisionRadius:, ShipEntity::behaviour_avoid_collision:, ShipEntity::behaviour_face_destination:, ShipEntity::behaviour_fly_from_destination:, ShipEntity::behaviour_fly_range_from_destination:, ShipEntity::behaviour_fly_to_destination:, ShipEntity::behaviour_fly_to_target_six:, ShipEntity::behaviour_formation_form_up:, ShipEntity::behaviour_intercept_target:, ShipEntity::behaviour_tractored:, OOTextureSprite::blitBackgroundCentredToX:Y:Z:alpha:, Universe::countEntitiesMatchingPredicate:parameter:inRange:ofEntity:, GuiDisplayGen(Internal)::drawStarChart:y:z:alpha:compact:, OOCommodities(OOPrivate)::economicBiasForGood:inEconomy:, Universe::findConnectedSystemAtCoords:withGalaxy:, Universe::findNeighbouringSystemToCoords:withGalaxy:, Universe::findSystemNumberAtCoords:withGalaxy:includingHidden:, WormholeEntity::initWormholeTo:fromShip:, PlayerEntity::leaveWitchspace, HeadUpDisplay::nonlinearScannerFunc, nonlinearScannerFunc(), Universe::routeFromSystem:toSystem:optimizedBy:, PlayerEntity::setGuiToSystemDataScreenRefreshBackground:, WormholeEntity::setMisjump, WormholeEntity::setMisjumpWithRange:, ShipFindNearestStation(), ShipFindNearestStation(), travelTimeBetweenPlanetPositions(), and PlayerEntity(OOPrivate)::witchJumpTo:misjump:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ distance2()

OOINLINE OOScalar distance2 ( Vector v1,
Vector v2 )

Definition at line 275 of file OOVector.h.

276{
277 return magnitude2(vector_subtract(v1, v2));
278}
OOINLINE OOScalar magnitude2(Vector vec) INLINE_CONST_FUNC
Definition OOVector.h:237

References magnitude2(), OOINLINE, and vector_subtract().

Referenced by OOMesh(Private)::FaceArea.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dot_product()

OOINLINE OOScalar dot_product ( Vector first,
Vector second )

Definition at line 299 of file OOVector.h.

300{
301 return (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
302}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by ShipEntity::approachAspectToPrimaryTarget, ShipEntity::ballTrackLeadingTarget:atTarget:, ShipEntity::behaviour_fly_to_destination:, OOMesh(Private)::calculateVertexNormalsAndTangentsWithFaceRefs:, OOMesh(Private)::calculateVertexTangentsWithFaceRefs:, ShipEntity::canScoop:, ShipEntity::checkCloseCollisionWith:, DockEntity::clearDockingCorridor, ShipEntity::collideWithShip:, PlayerEntity::customViewPanDown:, PlayerEntity::customViewPanLeft:, PlayerEntity::customViewPanRight:, PlayerEntity::customViewPanUp:, ShipEntity::dealEnergyDamage:atRange:withBias:, WormholeEntity::disgorgeShips, ShipEntity::doesHitLine:v1:, PlayerEntity::doesHitLine:v1:hitEntity:, ShipEntity::doesHitLine:v1:hitEntity:, ShipEntity::doesHitLine:v1:withPosition:i:j:k:, HeadUpDisplay(Private)::drawDirectionCue:, ShipEntity::evasiveAction:, OOMesh::findBoundingBoxRelativeToPosition:ri:rj:rk:selfPosition:si:sj:sk:, ShipEntity::fireLaserShotInDirection:weaponIdentifier:, ShipEntity::fireSubentityLaserShot:, Universe::firstEntityTargetedByPlayer, Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, OOMesh(Private)::generateFaceTangents, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, PlayerEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::missileTrackPrimaryTarget:, ShipEntity::onTarget:withWeapon:, resolveVectorInIJK(), ShipEntity::rollToMatchUp:rotating:, PlayerEntity::setCustomViewDataFromDictionary:withScaling:, ShipEntity::setProximityAlert:, CollisionRegion::shadowAtPointOcclusionToValue, DockEntity::shipIsInDockingCorridor:, PlayerEntity::takeEnergyDamage:from:becauseOf:weaponIdentifier:, PlayerEntity::takeScrapeDamage:from:, ShipEntity::trackDestination:retreat:, ShipEntity::trackPrimaryTarget:retreat:, ShipEntity::trackSideTarget:leftside:, triple_product(), and ShipEntity::update:.

Here is the caller graph for this function:

◆ magnitude()

OOINLINE OOScalar magnitude ( Vector vec)

◆ magnitude2()

◆ make_vector()

OOINLINE Vector make_vector ( OOScalar vx,
OOScalar vy,
OOScalar vz )

Definition at line 149 of file OOVector.h.

150{
151 Vector result;
152 result.x = vx;
153 result.y = vy;
154 result.z = vz;
155 return result;
156}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by Universe::addShips:withRole:nearPosition:withCoordinateSystem:, Universe::addShips:withRole:nearPosition:withCoordinateSystem:withinRadius:, basis_vectors_from_quaternion(), ShipEntity::checkCloseCollisionWith:, DockEntity::clearDockingCorridor, ShipEntity::doesHitLine:v1:, PlayerEntity::doesHitLine:v1:hitEntity:, ShipEntity::doesHitLine:v1:hitEntity:, ShipEntity::doesHitLine:v1:withPosition:i:j:k:, HeadUpDisplay(Private)::drawAegis:, HeadUpDisplay::drawIconForEmptyPylonAtX:y:width:height:alpha:, HeadUpDisplay::drawIconForMissile:selected:status:x:y:width:height:alpha:, OOLaserShotEntity::drawImmediate:translucent:, OOVisualEffectEntity::drawImmediate:translucent:, HeadUpDisplay(Private)::drawScanner:, OOTrumble::drawTrumble:, fillSquareImageWithPlanetTex(), Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, HeadUpDisplay::hudRotateViewpointForVirtualDepth, GuiDisplayGen::init, OOParticleSystem::initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:, Octree::isHitByLine, lineIntersectionWithFace(), OOMesh(Private)::loadData:scaleFactor:, NSPointToVectorJSValue(), NSPointToVectorJSValue(), Octree::offsetForOctant, OOPolygonSprite(OOHUDBeaconIcon)::oo_drawHUDBeaconIconAt:size:alpha:z:, OOMatrixGetBasisVectors(), OORandomUnitVector(), OOVectorInterpolate(), OOVectorMultiplyMatrix(), OOVectorRandomSpatial(), OOVectorTowards(), OOCrosshairs::render, PlanetEntity(OOPrivate)::scaleVertices, ScanVectorFromString(), PlayerEntity::setDefaultViewOffsets, DockEntity::setDimensionsAndCorridor:ddc:launching:, ShipEntity(PureAI)::setPlanetPatrolCoordinates, StationEntity::setUpShipFromDictionary:, SplitGeometryX(), SplitGeometryY(), SplitGeometryZ(), PlayerEntity::takeEnergyDamage:from:becauseOf:weaponIdentifier:, PlayerEntity::takeScrapeDamage:from:, OOExhaustPlumeEntity::update:, ShipEntity::update:, Universe::update:, DustEntity::updateCameraRelativePosition, vector_forward_from_quaternion(), vector_right_from_quaternion(), and vector_up_from_quaternion().

Here is the caller graph for this function:

◆ MakeVector2D()

OOINLINE Vector2D MakeVector2D ( OOScalar vx,
OOScalar vy )

Definition at line 158 of file OOVector.h.

159{
160 Vector2D result;
161 result.x = vx;
162 result.y = vy;
163 return result;
164}
OOScalar y
Definition OOVector.h:39
OOScalar x
Definition OOVector.h:38

References OOINLINE, Vector2D::x, and Vector2D::y.

◆ normal_to_surface()

OOINLINE Vector normal_to_surface ( Vector v1,
Vector v2,
Vector v3 )

Definition at line 309 of file OOVector.h.

310{
311 Vector d0, d1;
312 d0 = vector_subtract(v2, v1);
313 d1 = vector_subtract(v3, v2);
314 return cross_product(d0, d1);
315}
OOINLINE Vector cross_product(Vector first, Vector second) INLINE_CONST_FUNC
Definition OOVector.h:294

References cross_product(), OOINLINE, and vector_subtract().

Referenced by OOMesh(Private)::checkNormalsAndAdjustWinding.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OORandomUnitVector()

Vector OORandomUnitVector ( void )

Definition at line 76 of file OOVector.m.

77{
78 Vector v;
79 float m;
80
81 do {
82 v = make_vector(randf() - 0.5f, randf() - 0.5f, randf() - 0.5f);
83 m = magnitude2(v);
84 } while (m > 0.25f || m == 0.0f); // We're confining to a sphere of radius 0.5 using the sqared magnitude; 0.5 squared is 0.25.
85
86 return vector_normal(v);
87}
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
Definition OOVector.h:149
float randf(void)

References magnitude2(), make_vector(), randf(), and vector_normal().

Referenced by OOParticleSystem::initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:, and OOVectorRandomRadial().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOVectorInterpolate()

OOINLINE Vector OOVectorInterpolate ( Vector a,
Vector b,
OOScalar where )

Definition at line 204 of file OOVector.h.

205{
206 return make_vector(OOLerp(a.x, b.x, where),
207 OOLerp(a.y, b.y, where),
208 OOLerp(a.z, b.z, where));
209}
OOINLINE float OOLerp(float v0, float v1, float fraction) INLINE_CONST_FUNC

References make_vector(), OOINLINE, OOLerp(), Vector::x, Vector::y, and Vector::z.

Here is the call graph for this function:

◆ OOVectorRandomRadial()

Vector OOVectorRandomRadial ( OOScalar maxLength)

Definition at line 102 of file OOVector.m.

103{
104 return vector_multiply_scalar(OORandomUnitVector(), randf() * maxLength);
105}
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
Definition OOVector.h:180
Vector OORandomUnitVector(void)
Definition OOVector.m:76

References OORandomUnitVector(), randf(), and vector_multiply_scalar().

Referenced by HeadUpDisplay(Private)::drawScanner:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOVectorRandomSpatial()

Vector OOVectorRandomSpatial ( OOScalar maxLength)

Definition at line 89 of file OOVector.m.

90{
91 Vector v;
92 float m;
93
94 do {
95 v = make_vector(randf() - 0.5f, randf() - 0.5f, randf() - 0.5f);
96 m = magnitude2(v);
97 } while (m > 0.25f); // We're confining to a sphere of radius 0.5 using the sqared magnitude; 0.5 squared is 0.25.
98
99 return vector_multiply_scalar(v, maxLength * 2.0f); // 2.0 is to compensate for the 0.5-radius sphere.
100}

References magnitude2(), make_vector(), randf(), and vector_multiply_scalar().

Referenced by ShipEntity(PureAI)::setDestinationToJinkPosition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOVectorTowards()

OOINLINE Vector OOVectorTowards ( Vector a,
Vector b,
OOScalar where )

Definition at line 211 of file OOVector.h.

212{
213 return make_vector(a.x + b.x * where,
214 a.y + b.y * where,
215 a.z + b.z * where);
216}

References make_vector(), OOINLINE, Vector::x, Vector::y, and Vector::z.

Here is the call graph for this function:

◆ scale_vector()

OOINLINE void scale_vector ( Vector * outVector,
OOScalar factor )

Definition at line 166 of file OOVector.h.

167{
168 /*
169 Clang static analyzer: reports an unintialized value here when called
170 from -[HeadUpDisplay rescaleByFactor:]. This is blatantly wrong, as
171 the array the vector comes from is fully initialized in the range being
172 looped over.
173 -- Ahruman 2012-09-14
174 */
175 vec->x *= factor;
176 vec->y *= factor;
177 vec->z *= factor;
178}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by ShipEntity::applyThrust:, PlayerEntity::customViewRollLeft:, PlayerEntity::customViewRollRight:, PlayerEntity::customViewRotateDown:, PlayerEntity::customViewRotateLeft:, PlayerEntity::customViewRotateRight:, PlayerEntity::customViewRotateUp:, PlayerEntity::customViewZoomIn:, PlayerEntity::customViewZoomOut:, HeadUpDisplay(Private)::drawScanner:, and PlayerEntity(OOControlsPrivate)::pollCustomViewControls.

Here is the caller graph for this function:

◆ triple_product()

OOINLINE OOScalar triple_product ( Vector first,
Vector second,
Vector third )

Definition at line 304 of file OOVector.h.

305{
306 return dot_product(first, true_cross_product(second, third));
307}
OOINLINE OOScalar dot_product(Vector first, Vector second) INLINE_CONST_FUNC
Definition OOVector.h:299

References dot_product(), OOINLINE, and true_cross_product().

Here is the call graph for this function:

◆ true_cross_product()

OOINLINE Vector true_cross_product ( Vector first,
Vector second )

Definition at line 285 of file OOVector.h.

286{
287 Vector result;
288 result.x = (first.y * second.z) - (first.z * second.y);
289 result.y = (first.z * second.x) - (first.x * second.z);
290 result.z = (first.x * second.y) - (first.y * second.x);
291 return result;
292}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by cross_product(), OOMesh(Private)::FaceAreaCorrect, and triple_product().

Here is the caller graph for this function:

◆ vector_add()

OOINLINE Vector vector_add ( Vector a,
Vector b )

Definition at line 195 of file OOVector.h.

196{
197 Vector r;
198 r.x = a.x + b.x;
199 r.y = a.y + b.y;
200 r.z = a.z + b.z;
201 return r;
202}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by ShipEntity::addImpactMoment:fraction:, ShipEntity::adjustVelocity:, ShipEntity::ballTrackLeadingTarget:atTarget:, PlanetEntity::baseVertexIndexForEdge, OOMesh(Private)::calculateVertexNormalsAndTangentsWithFaceRefs:, OOMesh(Private)::calculateVertexTangentsWithFaceRefs:, PlayerEntity::customViewRollLeft:, PlayerEntity::customViewRollRight:, PlayerEntity::customViewRotateDown:, PlayerEntity::customViewRotateLeft:, PlayerEntity::customViewRotateRight:, PlayerEntity::customViewRotateUp:, PlayerEntity::customViewZoomIn:, PlayerEntity::customViewZoomOut:, HeadUpDisplay(Private)::drawScanner:, ShipEntity::dumpItem:, OOMesh::findSubentityBoundingBoxWithPosition:rotMatrix:, ShipEntity::fireMissileWithIdentifier:andTarget:, OOMesh(Private)::getNormal:andTangent:forVertex:inSmoothGroup:, Octree::isHitByOctree, ShipEntity::launchCascadeMine, PlayerEntity::launchEscapeCapsule, DockEntity::launchShip:, OOBoundingBoxCenter(), PlayerEntity(OOControlsPrivate)::pollCustomViewControls, PlayerEntity(Scripting)::processSceneString:atOffset:, Octree::randomFullNodeFrom, ShipEntity(PureAI)::setDestinationToJinkPosition, OOSkyDrawable(OOPrivate)::setUpNebulaeWithColor1:color2:clusterFactor:nebulaHueFix:alpha:scale:, OOSkyDrawable(OOPrivate)::setUpStarsWithColor1:color2:, OOExhaustPlumeEntity::update:, OOParticleSystem::update:, and ShipEntity::velocity.

Here is the caller graph for this function:

◆ vector_equal()

OOINLINE bool vector_equal ( Vector a,
Vector b )

Definition at line 232 of file OOVector.h.

233{
234 return a.x == b.x && a.y == b.y && a.z == b.z;
235}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by OOMesh(Private)::checkNormalsAndAdjustWinding, OOMesh::findSubentityBoundingBoxWithPosition:rotMatrix:, ShipEntity::missileTrackPrimaryTarget:, OOTriangleIsDegenerate(), quaternion_rotation_between(), ShipEntity::trackDestination:retreat:, ShipEntity::trackPrimaryTarget:retreat:, ShipEntity::trackSideTarget:leftside:, ShipEntity::update:, and Verify_Vector().

Here is the caller graph for this function:

◆ vector_flip()

OOINLINE Vector vector_flip ( Vector v)

Definition at line 227 of file OOVector.h.

228{
229 return vector_subtract(kZeroVector, v);
230}
const Vector kZeroVector
Definition OOVector.m:27

References kZeroVector, OOINLINE, and vector_subtract().

Referenced by OOMesh(Private)::checkNormalsAndAdjustWinding, PlayerEntity::customViewRollLeft:, PlayerEntity::customViewRollRight:, PlayerEntity::customViewRotateDown:, PlayerEntity::customViewRotateLeft:, PlayerEntity::customViewRotateRight:, PlayerEntity::customViewRotateUp:, HeadUpDisplay(Private)::drawDirectionCue:, Universe::drawUniverse, Universe::getActiveViewMatrix:forwardVector:upVector:, Octree::isHitByOctree, PlayerEntity(OOControlsPrivate)::pollCustomViewControls, and DustEntity::update:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_multiply_scalar()

OOINLINE Vector vector_multiply_scalar ( Vector v,
OOScalar s )

Definition at line 180 of file OOVector.h.

181{
182 /*
183 Clang static analyzer: reports a garbage value here when called from
184 -[OOMesh rescaleByFactor:], apparently on baseless assumption that
185 OOMesh._vertices points to only one vertex.
186 -- Ahruman 2012-09-14
187 */
188 Vector r;
189 r.x = v.x * s;
190 r.y = v.y * s;
191 r.z = v.z * s;
192 return r;
193}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by ShipEntity::addImpactMoment:fraction:, ShipEntity::ballTrackLeadingTarget:atTarget:, StationEntity::beaconPosition, ShipEntity::becomeExplosion, OOMesh(Private)::calculateVertexNormalsAndTangentsWithFaceRefs:, OOMesh(Private)::calculateVertexTangentsWithFaceRefs:, ShipEntity::collideWithShip:, PlayerEntity::customViewPanDown:, PlayerEntity::customViewPanLeft:, PlayerEntity::customViewPanRight:, PlayerEntity::customViewPanUp:, PlayerEntity::customViewZoomIn:, PlayerEntity::customViewZoomOut:, WormholeEntity::disgorgeShips, OOParticleSystem::drawImmediate:translucent:, ShipEntity::dumpItem:, ShipEntity::fireDirectLaserShotAt:, ShipEntity::fireLaserShotInDirection:weaponIdentifier:, ShipEntity::fireMissileWithIdentifier:andTarget:, ShipEntity::fireSubentityLaserShot:, ShipEntity::fireTurretCannon:, Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, OOMesh(Private)::generateFaceTangents, OOMesh(Private)::getNormal:andTangent:forVertex:inSmoothGroup:, ShipEntity::getWeaponOffsetFrom:withKey:inMode:, ShipEntity(PureAI)::getWitchspaceEntryCoordinates, OOExplosionCloudEntity(OOPrivate)::initExplosionCloudWithEntity:size:andSettings:, OOLaserShotEntity::initLaserFromShip:direction:offset:, OOParticleSystem::initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:, ShipEntity::launchCascadeMine, PlayerEntity::launchEscapeCapsule, PlayerEntity::launchMine:, DockEntity::launchShip:, PlayerEntity::leaveWitchspace, ShipEntity::missileLaunchPosition, HeadUpDisplay::nonlinearScannerScale:Zoom:Scale:, OOBoundingBoxCenter(), OOVectorRandomRadial(), OOVectorRandomSpatial(), PlayerEntity(OOPrivate)::performInFlightUpdates:, PlayerEntity(OOControlsPrivate)::pollCustomViewControls, PlayerEntity(Scripting)::processSceneString:atOffset:, OOExhaustPlumeEntity::rescaleBy:, OOMesh(Private)::rescaleByFactor:, PlayerEntity::setCustomViewDataFromDictionary:withScaling:, ShipEntity(PureAI)::setDestinationToJinkPosition, Universe::setUpBreakPattern:orientation:forDocking:, OOSkyDrawable(OOPrivate)::setUpNebulaeWithColor1:color2:clusterFactor:nebulaHueFix:alpha:scale:, PlayerEntity::setUpShipFromDictionary:, Universe::setUpSpace, OOSkyDrawable(OOPrivate)::setUpStarsWithColor1:color2:, Universe::spawnShipWithRole:near:, ShipEntity::throwSparks, ShipEntity::thrustVector, OOExhaustPlumeEntity::update:, OOParticleSystem::update:, ShipEntity::update:, vector_normal_or_fallback(), and DustEntity::warpVector.

Here is the caller graph for this function:

◆ vector_normal()

OOINLINE Vector vector_normal ( Vector vec)

Definition at line 270 of file OOVector.h.

271{
273}
OOINLINE Vector vector_normal_or_fallback(Vector vec, Vector fallback) INLINE_CONST_FUNC
Definition OOVector.h:247

References kZeroVector, OOINLINE, and vector_normal_or_fallback().

Referenced by ShipEntity::approachAspectToPrimaryTarget, PlanetEntity::baseVertexIndexForEdge, basis_vectors_from_quaternion(), ShipEntity::becomeExplosion, DockEntity::clearDockingCorridor, cross_product(), ShipEntity::dealEnergyDamage:atRange:withBias:, HeadUpDisplay(Private)::drawDirectionCue:, ShipEntity::dumpItem:, fillSquareImageWithPlanetTex(), ShipEntity::fireLaserShotInDirection:weaponIdentifier:, ShipEntity::fireMissileWithIdentifier:andTarget:, ShipEntity::fireSubentityLaserShot:, OOMesh(Private)::generateFaceTangents, OOExplosionCloudEntity(OOPrivate)::initExplosionCloudWithEntity:size:andSettings:, OOParticleSystem::initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:, OOMesh(Private)::loadData:scaleFactor:, OOOpenGLMatrixManager::lookAtWithEye:center:up:, ShipEntity::missileTrackPrimaryTarget:, HeadUpDisplay::nonlinearScannerScale:Zoom:Scale:, OOMatrixForRotation(), OOMatrixOrthogonalize(), OORandomUnitVector(), PlayerEntity(OOControlsPrivate)::pollCustomViewControls, ShipEntity::trackDestination:retreat:, ShipEntity::trackOntoTarget:withDForward:, ShipEntity::trackPrimaryTarget:retreat:, ShipEntity::trackSideTarget:leftside:, vector_forward_from_quaternion(), vector_right_from_quaternion(), and vector_up_from_quaternion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_normal_or_fallback()

OOINLINE Vector vector_normal_or_fallback ( Vector vec,
Vector fallback )

Definition at line 247 of file OOVector.h.

248{
249 OOScalar mag2 = magnitude2(vec);
250 if (EXPECT_NOT(mag2 == 0.0f))
251 return fallback;
252 return vector_multiply_scalar(vec, 1.0f / sqrt(mag2));
253}
#define EXPECT_NOT(x)
GLfloat OOScalar
Definition OOMaths.h:49

References EXPECT_NOT, magnitude2(), OOINLINE, and vector_multiply_scalar().

Referenced by ShipEntity::ballTrackLeadingTarget:atTarget:, OOMesh(Private)::calculateVertexNormalsAndTangentsWithFaceRefs:, OOMesh(Private)::calculateVertexTangentsWithFaceRefs:, HeadUpDisplay(Private)::drawCompass:, OOMesh(Private)::getNormal:andTangent:forVertex:inSmoothGroup:, OOMatrixForBillboard(), vector_normal(), vector_normal_or_xbasis(), vector_normal_or_ybasis(), and vector_normal_or_zbasis().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_normal_or_xbasis()

OOINLINE Vector vector_normal_or_xbasis ( Vector vec)

Definition at line 255 of file OOVector.h.

256{
258}
const Vector kBasisXVector
Definition OOVector.h:45

References kBasisXVector, OOINLINE, and vector_normal_or_fallback().

Referenced by CollisionRegion::shadowAtPointOcclusionToValue.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_normal_or_ybasis()

OOINLINE Vector vector_normal_or_ybasis ( Vector vec)

Definition at line 260 of file OOVector.h.

261{
263}
const Vector kBasisYVector
Definition OOVector.h:46

References kBasisYVector, OOINLINE, and vector_normal_or_fallback().

Here is the call graph for this function:

◆ vector_normal_or_zbasis()

OOINLINE Vector vector_normal_or_zbasis ( Vector vec)

Definition at line 265 of file OOVector.h.

266{
268}
const Vector kBasisZVector
Definition OOVector.h:47

References kBasisZVector, OOINLINE, and vector_normal_or_fallback().

Referenced by ShipEntity::fireDirectLaserShotAt:, PlayerEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::onTarget:withWeapon:, and CollisionRegion::shadowAtPointOcclusionToValue.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_subtract()

OOINLINE Vector vector_subtract ( Vector a,
Vector b )

Definition at line 218 of file OOVector.h.

219{
220 Vector r;
221 r.x = a.x - b.x;
222 r.y = a.y - b.y;
223 r.z = a.z - b.z;
224 return r;
225}

References OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by ShipEntity::behaviour_attack_target:, calculateNormalForTriangle(), OOMesh(Private)::calculateVertexNormalsAndTangentsWithFaceRefs:, OOMesh(Private)::calculateVertexTangentsWithFaceRefs:, ShipEntity::collideWithShip:, PlayerEntity::customViewPanDown:, PlayerEntity::customViewPanLeft:, PlayerEntity::customViewPanRight:, PlayerEntity::customViewPanUp:, PlayerEntity::customViewRollLeft:, PlayerEntity::customViewRollRight:, PlayerEntity::customViewRotateDown:, PlayerEntity::customViewRotateLeft:, PlayerEntity::customViewRotateRight:, PlayerEntity::customViewRotateUp:, PlayerEntity::customViewZoomIn:, PlayerEntity::customViewZoomOut:, ShipEntity::dealEnergyDamage:atRange:withBias:, distance(), distance2(), DustEntity::drawImmediate:translucent:, OOMesh(Private)::FaceAreaCorrect, OOMesh::findBoundingBoxRelativeToPosition:ri:rj:rk:selfPosition:si:sj:sk:, OOMesh(Private)::generateFaceTangents, Octree::isHitByOctree, PlayerEntity::launchMine:, OOOpenGLMatrixManager::lookAtWithEye:center:up:, normal_to_surface(), PlayerEntity(OOControlsPrivate)::pollCustomViewControls, PlayerEntity(Scripting)::processSceneString:atOffset:, PlayerEntity::setCustomViewDataFromDictionary:withScaling:, OOSkyDrawable(OOPrivate)::setUpNebulaeWithColor1:color2:clusterFactor:nebulaHueFix:alpha:scale:, OOSkyDrawable(OOPrivate)::setUpStarsWithColor1:color2:, and vector_flip().

Here is the caller graph for this function:

Variable Documentation

◆ kBasisXVector

◆ kBasisXVector2D

const Vector2D kBasisXVector2D

Definition at line 50 of file OOVector.h.

◆ kBasisYVector

◆ kBasisYVector2D

const Vector2D kBasisYVector2D

Definition at line 51 of file OOVector.h.

◆ kBasisZVector

◆ kZeroVector

const Vector kZeroVector
extern

Definition at line 27 of file OOVector.m.

27{ 0.0f, 0.0f, 0.0f };

Referenced by ShipEntity::behaviour_attack_broadside:, ShipEntity::behaviour_attack_fly_from_target:, ShipEntity::behaviour_attack_target:, ShipEntity::behaviour_running_defense:, OOMesh(Private)::calculateVertexNormalsAndTangentsWithFaceRefs:, OOMesh(Private)::calculateVertexTangentsWithFaceRefs:, OOMesh(Private)::checkNormalsAndAdjustWinding, ShipEntity::collideWithShip:, HeadUpDisplay(Private)::drawDirectionCue:, OOECMBlastEntity::drawImmediate:translucent:, Universe::drawUniverse, PlayerEntity::engageAutopilotToStation:, ShipEntity::fireMissileWithIdentifier:andTarget:, Universe::firstEntityTargetedByPlayerPrecisely, PlayerEntity::getDestroyedBy:damageType:, OOMesh(Private)::getNormal:andTangent:forVertex:inSmoothGroup:, ShipEntity::getWeaponOffsetFrom:withKey:inMode:, HeadUpDisplay::hudRotateViewpointForVirtualDepth, OOMesh::init, OOSoundSource::init, Octree::isHitByLine:v1:, PlayerEntity::leaveDock:, PlayerEntity::leaveWitchspace, ShipEntity::missileTrackPrimaryTarget:, OOMatrixFromBasisVectors(), PlayerEntity(OOPrivate)::performInFlightUpdates:, PlayerShipSetCustomView(), PlayerShipSetCustomView(), StationEntity::portUpVectorForShip:, ShipEntity::positionOffsetForAlignment:, ShipEntity::positionOffsetForShipInRotationToAlignment, Octree::randomPoint, ShipEntity(Private)::refreshEscortPositions, OOExhaustPlumeEntity::resetPlume, PlayerEntity::setCustomViewDataFromDictionary:withScaling:, PlayerEntity::setDefaultViewOffsets, ShipEntity::setEvasiveJink:, PlayerEntity::setUpAndConfirmOK:saveGame:, OOVisualEffectEntity::setUpVisualEffectFromDictionary:, SystemSetPopulator(), SystemSetPopulator(), ShipEntity::trackDestination:retreat:, ShipEntity::trackPrimaryTarget:retreat:, ShipEntity::trackSideTarget:leftside:, ShipEntity::update:, OOShipRegistry(OODataLoader)::validateNewStyleFlasherDeclaration:forShip:fatalError:, OOShipRegistry(OODataLoader)::validateNewStyleStandardSubentityDeclaration:forShip:fatalError:, vector_flip(), vector_normal(), Verify_Vector(), PlayerEntity::viewpointOffset, PlayerEntity::weaponViewOffset, and ShipEntity::witchspaceLeavingEffects.

◆ kZeroVector2D

const Vector2D kZeroVector2D
extern

Definition at line 32 of file OOVector.m.

32{ 0.0f, 0.0f };