ObjFW  Check-in [b924571763]

Overview
Comment:OFMatrix4x4: Don't create a singleton

A singleton for the identity matrix makes no sense since OFMatrix4x4 is
mutable.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b92457176324e566354afc51cddb3e89fc1256cc27627bea5fa4d139ca90e50a
User & Date: js on 2023-02-18 23:53:12
Other Links: manifest | tags
Context
2023-02-19
13:37
OFMatrix4x4: Use 2D arrays in row-major format check-in: 975a812f36 user: js tags: trunk
2023-02-18
23:53
OFMatrix4x4: Don't create a singleton check-in: b924571763 user: js tags: trunk
12:01
OFMatrix4x4: Transform vectors in 4D space check-in: e31a31bdcb user: js tags: trunk
Changes

Modified src/OFMatrix4x4.m from [2f91cc67c5] to [81834eec17].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

static const float identityValues[16] = {
	1, 0, 0, 0,
	0, 1, 0, 0,
	0, 0, 1, 0,
	0, 0, 0, 1
};
static OFMatrix4x4 *identityMatrix;

static void
initIdentityMatrix(void)
{
	identityMatrix = [[OFMatrix4x4 alloc] initWithValues: identityValues];
}

@implementation OFMatrix4x4
+ (void)initialize
{
	if (self != [OFMatrix4x4 class])
		return;
}

+ (OFMatrix4x4 *)identityMatrix
{
	static OFOnceControl onceControl = OFOnceControlInitValue;
	OFOnce(&onceControl, initIdentityMatrix);

	return identityMatrix;
}

+ (instancetype)matrixWithValues: (const float [16])values
{
	return [[[self alloc] initWithValues: values] autorelease];
}








<

<
<
<
<
<
<

<
<
<
<
<
<


<
<
|
|







21
22
23
24
25
26
27

28






29






30
31


32
33
34
35
36
37
38
39
40

static const float identityValues[16] = {
	1, 0, 0, 0,
	0, 1, 0, 0,
	0, 0, 1, 0,
	0, 0, 0, 1
};








@implementation OFMatrix4x4






+ (OFMatrix4x4 *)identityMatrix
{


	return [[[OFMatrix4x4 alloc]
	    initWithValues: identityValues] autorelease];
}

+ (instancetype)matrixWithValues: (const float [16])values
{
	return [[[self alloc] initWithValues: values] autorelease];
}