/
surface.cpp
760 lines (617 loc) · 20.5 KB
/
surface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
/** @file surface.cpp World map surface.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#include <de/memoryzone.h> /// @todo remove me
#include <de/Log>
#include "de_platform.h"
#include "de_defs.h" // Def_GetGenerator
#include "Materials"
#include "world/map.h"
#include "world/world.h" // ddMapSetup
#include "render/r_main.h" // frameTimePos
#ifdef __CLIENT__
# include "gl/gl_tex.h"
# include "gl/gl_texmanager.h"
# include "render/rend_main.h"
#endif
#include "world/surface.h"
using namespace de;
DENG2_PIMPL(Surface)
{
/// Tangent space matrix.
Matrix3f tangentMatrix;
bool needUpdateTangentMatrix; ///< @c true= marked for update.
/// Bound material.
Material *material;
/// @c true= Bound material is a "missing material fix".
bool materialIsMissingFix;
/// @em Sharp origin of the surface material.
Vector2f materialOrigin;
#ifdef __CLIENT__
/// Old @em sharp origin of the surface material, for smoothing.
Vector2f oldMaterialOrigin[2];
/// Smoothed origin of the surface material.
Vector2f visMaterialOrigin;
/// Delta between the @em sharp and smoothed origin of the surface material.
Vector2f visMaterialOriginDelta;
#endif
/// Surface color tint.
de::Vector3f tintColor;
/// Surface opacity.
float opacity;
/// Blending mode.
blendmode_t blendMode;
/// @ref sufFlags
int flags;
Instance(Public *i)
: Base(i),
tangentMatrix(Matrix3f::Zero),
needUpdateTangentMatrix(false),
material(0),
materialIsMissingFix(false),
blendMode(BM_NORMAL),
flags(0)
{}
#ifdef DENG_DEBUG
inline bool isSideMiddle()
{
return self.parent().type() == DMU_SIDE &&
&self == &self.parent().as<LineSide>().middle();
}
inline bool isSectorExtraPlane()
{
if(self.parent().type() != DMU_PLANE) return false;
Plane const &plane = self.parent().as<Plane>();
return !(plane.isSectorFloor() || plane.isSectorCeiling());
}
#endif
void notifyNormalChanged(Vector3f const &oldNormal)
{
// Predetermine which axes have changed.
int changedAxes = 0;
for(int i = 0; i < 3; ++i)
{
if(!de::fequal(tangentMatrix.at(i, 2), oldNormal[i]))
changedAxes |= (1 << i);
}
DENG2_FOR_PUBLIC_AUDIENCE(NormalChange, i)
{
i->normalChanged(self, oldNormal, changedAxes);
}
}
void notifyMaterialOriginChanged(Vector2f const &oldMaterialOrigin,
int changedComponents)
{
DENG2_FOR_PUBLIC_AUDIENCE(MaterialOriginChange, i)
{
i->materialOriginChanged(self, oldMaterialOrigin, changedComponents);
}
#ifdef __CLIENT__
if(!ddMapSetup)
{
/// @todo Replace with a de::Observer-based mechanism.
self._decorationData.needsUpdate = true;
self.map().scrollingSurfaces().insert(&self);
}
#endif
}
void notifyMaterialOriginChanged(Vector2f const &oldMaterialOrigin)
{
// Predetermine which axes have changed.
int changedAxes = 0;
for(int i = 0; i < 2; ++i)
{
if(!de::fequal(materialOrigin[i], oldMaterialOrigin[i]))
changedAxes |= (1 << i);
}
notifyMaterialOriginChanged(oldMaterialOrigin, changedAxes);
}
void notifyOpacityChanged(float oldOpacity)
{
DENG2_FOR_PUBLIC_AUDIENCE(OpacityChange, i)
{
i->opacityChanged(self, oldOpacity);
}
}
void notifyTintColorChanged(Vector3f const &oldTintColor, int changedComponents)
{
DENG2_FOR_PUBLIC_AUDIENCE(TintColorChange, i)
{
i->tintColorChanged(self, oldTintColor, changedComponents);
}
}
void notifyTintColorChanged(Vector3f const &oldTintColor)
{
// Predetermine which components have changed.
int changedComponents = 0;
for(int i = 0; i < 3; ++i)
{
if(!de::fequal(tintColor[i], oldTintColor[i]))
changedComponents |= (1 << i);
}
notifyTintColorChanged(oldTintColor, changedComponents);
}
void updateTangentMatrix()
{
needUpdateTangentMatrix = false;
dfloat values[9];
Vector3f normal = tangentMatrix.column(2);
V3f_Set(values + 6, normal.x, normal.y, normal.z);
V3f_BuildTangents(values, values + 3, values + 6);
tangentMatrix = Matrix3f(values);
}
};
Surface::Surface(MapElement &owner, float opacity, Vector3f const &tintColor)
: MapElement(DMU_SURFACE, &owner), d(new Instance(this))
{
#ifdef __CLIENT__
_decorationData.needsUpdate = true;
_decorationData.sources = 0;
_decorationData.numSources = 0;
#endif
d->opacity = opacity;
d->tintColor = tintColor;
}
Matrix3f const &Surface::tangentMatrix() const
{
// Perform any scheduled update now.
if(d->needUpdateTangentMatrix)
{
d->updateTangentMatrix();
}
return d->tangentMatrix;
}
void Surface::setNormal(Vector3f const &newNormal)
{
Vector3f oldNormal = normal();
Vector3f newNormalNormalized = newNormal.normalize();
if(oldNormal != newNormalNormalized)
{
d->tangentMatrix.at(0, 2) = newNormalNormalized.x;
d->tangentMatrix.at(1, 2) = newNormalNormalized.y;
d->tangentMatrix.at(2, 2) = newNormalNormalized.z;
// We'll need to recalculate the tangents when next referenced.
d->needUpdateTangentMatrix = true;
// Notify interested parties of the change.
d->notifyNormalChanged(oldNormal);
}
}
int Surface::flags() const
{
return d->flags;
}
void Surface::setFlags(int flagsToChange, FlagOp operation)
{
applyFlagOperation(d->flags, flagsToChange, operation);
}
bool Surface::hasMaterial() const
{
return d->material != 0;
}
bool Surface::hasFixMaterial() const
{
return d->material != 0 && d->materialIsMissingFix;
}
Material &Surface::material() const
{
if(d->material)
{
return *d->material;
}
/// @throw MissingMaterialError Attempted with no material bound.
throw MissingMaterialError("Surface::material", "No material is bound");
}
bool Surface::setMaterial(Material *newMaterial, bool isMissingFix)
{
if(d->material != newMaterial)
{
// Update the missing-material-fix state.
if(!d->material)
{
if(newMaterial && isMissingFix)
{
d->materialIsMissingFix = true;
// Sides of selfreferencing map lines should never receive fix materials.
DENG_ASSERT(!(parent().type() == DMU_SIDE && parent().as<LineSide>().line().isSelfReferencing()));
}
}
else if(newMaterial && d->materialIsMissingFix)
{
d->materialIsMissingFix = false;
}
d->material = newMaterial;
#ifdef __CLIENT__
if(!ddMapSetup)
{
map().unlinkInMaterialLists(this);
if(d->material)
{
map().linkInMaterialLists(this);
if(parent().type() == DMU_PLANE)
{
de::Uri uri = d->material->manifest().composeUri();
ded_ptcgen_t const *def = Def_GetGenerator(reinterpret_cast<uri_s *>(&uri));
P_SpawnPlaneParticleGen(def, &parent().as<Plane>());
}
}
}
/// @todo Replace with a de::Observer-based mechanism.
_decorationData.needsUpdate = true;
#endif // __CLIENT__
}
return true;
}
Vector2f const &Surface::materialOrigin() const
{
return d->materialOrigin;
}
void Surface::setMaterialOrigin(Vector2f const &newOrigin)
{
if(d->materialOrigin != newOrigin)
{
Vector2f oldMaterialOrigin = d->materialOrigin;
d->materialOrigin = newOrigin;
#ifdef __CLIENT__
// During map setup we'll apply this immediately to the visual origin also.
if(ddMapSetup)
{
d->visMaterialOrigin = d->materialOrigin;
d->visMaterialOriginDelta.x = d->visMaterialOriginDelta.y = 0;
d->oldMaterialOrigin[0] = d->oldMaterialOrigin[1] = d->materialOrigin;
}
#endif
// Notify interested parties of the change.
d->notifyMaterialOriginChanged(oldMaterialOrigin);
}
}
void Surface::setMaterialOriginComponent(int component, float newPosition)
{
if(!de::fequal(d->materialOrigin[component], newPosition))
{
Vector2f oldMaterialOrigin = d->materialOrigin;
d->materialOrigin[component] = newPosition;
#ifdef __CLIENT__
// During map setup we'll apply this immediately to the visual origin also.
if(ddMapSetup)
{
d->visMaterialOrigin[component] = d->materialOrigin[component];
d->visMaterialOriginDelta[component] = 0;
d->oldMaterialOrigin[0][component] =
d->oldMaterialOrigin[1][component] =
d->materialOrigin[component];
}
#endif
// Notify interested parties of the change.
d->notifyMaterialOriginChanged(oldMaterialOrigin, (1 << component));
}
}
de::Uri Surface::composeMaterialUri() const
{
if(!hasMaterial()) return de::Uri();
return material().manifest().composeUri();
}
#ifdef __CLIENT__
Vector2f const &Surface::visMaterialOrigin() const
{
return d->visMaterialOrigin;
}
Vector2f const &Surface::visMaterialOriginDelta() const
{
return d->visMaterialOriginDelta;
}
void Surface::lerpVisMaterialOrigin()
{
// $smoothmaterialorigin
d->visMaterialOriginDelta = d->oldMaterialOrigin[0] * (1 - frameTimePos)
+ d->materialOrigin * frameTimePos - d->materialOrigin;
// Visible material origin.
d->visMaterialOrigin = d->materialOrigin + d->visMaterialOriginDelta;
#ifdef __CLIENT__
markAsNeedingDecorationUpdate();
#endif
}
void Surface::resetVisMaterialOrigin()
{
// $smoothmaterialorigin
d->visMaterialOrigin = d->oldMaterialOrigin[0] = d->oldMaterialOrigin[1] = d->materialOrigin;
d->visMaterialOriginDelta.x = d->visMaterialOriginDelta.y = 0;
#ifdef __CLIENT__
markAsNeedingDecorationUpdate();
#endif
}
void Surface::updateMaterialOriginTracking()
{
// $smoothmaterialorigin
d->oldMaterialOrigin[0] = d->oldMaterialOrigin[1];
d->oldMaterialOrigin[1] = d->materialOrigin;
if(d->oldMaterialOrigin[0] != d->oldMaterialOrigin[1])
{
float moveDistance = de::abs(Vector2f(d->oldMaterialOrigin[1] - d->oldMaterialOrigin[0]).length());
if(moveDistance >= MAX_SMOOTH_MATERIAL_MOVE)
{
// Too fast: make an instantaneous jump.
d->oldMaterialOrigin[0] = d->oldMaterialOrigin[1];
}
}
}
#endif // __CLIENT__
float Surface::opacity() const
{
return d->opacity;
}
void Surface::setOpacity(float newOpacity)
{
DENG_ASSERT(d->isSideMiddle() || d->isSectorExtraPlane()); // sanity check
newOpacity = de::clamp(0.f, newOpacity, 1.f);
if(!de::fequal(d->opacity, newOpacity))
{
float oldOpacity = d->opacity;
d->opacity = newOpacity;
// Notify interested parties of the change.
d->notifyOpacityChanged(oldOpacity);
}
}
Vector3f const &Surface::tintColor() const
{
return d->tintColor;
}
void Surface::setTintColor(Vector3f const &newTintColor)
{
Vector3f newColorClamped = Vector3f(de::clamp(0.f, newTintColor.x, 1.f),
de::clamp(0.f, newTintColor.y, 1.f),
de::clamp(0.f, newTintColor.z, 1.f));
if(d->tintColor != newColorClamped)
{
Vector3f oldTintColor = d->tintColor;
d->tintColor = newColorClamped;
// Notify interested parties of the change.
d->notifyTintColorChanged(oldTintColor);
}
}
void Surface::setTintColorComponent(int component, float newStrength)
{
DENG_ASSERT(component >= 0 && component < 3);
newStrength = de::clamp(0.f, newStrength, 1.f);
if(!de::fequal(d->tintColor[component], newStrength))
{
Vector3f oldTintColor = d->tintColor;
d->tintColor[component] = newStrength;
// Notify interested parties of the change.
d->notifyTintColorChanged(oldTintColor, (1 << component));
}
}
blendmode_t Surface::blendMode() const
{
return d->blendMode;
}
void Surface::setBlendMode(blendmode_t newBlendMode)
{
if(d->blendMode != newBlendMode)
{
d->blendMode = newBlendMode;
}
}
#ifdef __CLIENT__
float Surface::glow(Vector3f &color) const
{
if(!d->material || !d->material->hasGlow())
{
color = Vector3f();
return 0;
}
MaterialSnapshot const &ms = d->material->prepare(Rend_MapSurfaceMaterialSpec());
averagecolor_analysis_t const *avgColorAmplified = reinterpret_cast<averagecolor_analysis_t const *>(ms.texture(MTU_PRIMARY).generalCase().analysisDataPointer(Texture::AverageColorAmplifiedAnalysis));
if(!avgColorAmplified) throw Error("Surface::glow", QString("Texture \"%1\" has no AverageColorAmplifiedAnalysis").arg(ms.texture(MTU_PRIMARY).generalCase().manifest().composeUri()));
color = Vector3f(avgColorAmplified->color.rgb);
return ms.glowStrength() * glowFactor; // Global scale factor.
}
Surface::DecorSource *Surface::newDecoration()
{
Surface::DecorSource *newSources =
(DecorSource *) Z_Malloc(sizeof(*newSources) * (++_decorationData.numSources), PU_MAP, 0);
if(_decorationData.numSources > 1)
{
// Copy the existing decorations.
for(int i = 0; i < _decorationData.numSources - 1; ++i)
{
Surface::DecorSource *d = &newSources[i];
Surface::DecorSource *s = &_decorationData.sources[i];
std::memcpy(d, s, sizeof(*d));
}
Z_Free(_decorationData.sources);
}
Surface::DecorSource *decor = &newSources[_decorationData.numSources - 1];
_decorationData.sources = newSources;
decor->_surface = this;
return decor;
}
void Surface::clearDecorations()
{
if(_decorationData.sources)
{
Z_Free(_decorationData.sources); _decorationData.sources = 0;
}
_decorationData.numSources = 0;
}
int Surface::decorationCount() const
{
return _decorationData.numSources;
}
void Surface::markAsNeedingDecorationUpdate()
{
if(ddMapSetup) return;
_decorationData.needsUpdate = true;
}
#endif // __CLIENT__
int Surface::property(DmuArgs &args) const
{
switch(args.prop)
{
case DMU_MATERIAL: {
Material *mat = d->material;
if(d->materialIsMissingFix)
mat = 0;
args.setValue(DMT_SURFACE_MATERIAL, &mat, 0);
break; }
case DMU_OFFSET_X:
args.setValue(DMT_SURFACE_OFFSET, &d->materialOrigin.x, 0);
break;
case DMU_OFFSET_Y:
args.setValue(DMT_SURFACE_OFFSET, &d->materialOrigin.y, 0);
break;
case DMU_OFFSET_XY:
args.setValue(DMT_SURFACE_OFFSET, &d->materialOrigin.x, 0);
args.setValue(DMT_SURFACE_OFFSET, &d->materialOrigin.y, 1);
break;
case DMU_TANGENT_X:
args.setValue(DMT_SURFACE_TANGENT, &d->tangentMatrix.at(0, 0), 0);
break;
case DMU_TANGENT_Y:
args.setValue(DMT_SURFACE_TANGENT, &d->tangentMatrix.at(1, 0), 0);
break;
case DMU_TANGENT_Z:
args.setValue(DMT_SURFACE_TANGENT, &d->tangentMatrix.at(2, 0), 0);
break;
case DMU_TANGENT_XYZ:
args.setValue(DMT_SURFACE_TANGENT, &d->tangentMatrix.at(0, 0), 0);
args.setValue(DMT_SURFACE_TANGENT, &d->tangentMatrix.at(1, 0), 1);
args.setValue(DMT_SURFACE_TANGENT, &d->tangentMatrix.at(2, 0), 2);
break;
case DMU_BITANGENT_X:
args.setValue(DMT_SURFACE_BITANGENT, &d->tangentMatrix.at(0, 1), 0);
break;
case DMU_BITANGENT_Y:
args.setValue(DMT_SURFACE_BITANGENT, &d->tangentMatrix.at(1, 1), 0);
break;
case DMU_BITANGENT_Z:
args.setValue(DMT_SURFACE_BITANGENT, &d->tangentMatrix.at(2, 1), 0);
break;
case DMU_BITANGENT_XYZ:
args.setValue(DMT_SURFACE_BITANGENT, &d->tangentMatrix.at(0, 1), 0);
args.setValue(DMT_SURFACE_BITANGENT, &d->tangentMatrix.at(1, 1), 1);
args.setValue(DMT_SURFACE_BITANGENT, &d->tangentMatrix.at(2, 1), 2);
break;
case DMU_NORMAL_X:
args.setValue(DMT_SURFACE_NORMAL, &d->tangentMatrix.at(0, 2), 0);
break;
case DMU_NORMAL_Y:
args.setValue(DMT_SURFACE_NORMAL, &d->tangentMatrix.at(1, 2), 0);
break;
case DMU_NORMAL_Z:
args.setValue(DMT_SURFACE_NORMAL, &d->tangentMatrix.at(2, 2), 0);
break;
case DMU_NORMAL_XYZ:
args.setValue(DMT_SURFACE_NORMAL, &d->tangentMatrix.at(0, 2), 0);
args.setValue(DMT_SURFACE_NORMAL, &d->tangentMatrix.at(1, 2), 1);
args.setValue(DMT_SURFACE_NORMAL, &d->tangentMatrix.at(2, 2), 2);
break;
case DMU_COLOR:
args.setValue(DMT_SURFACE_RGBA, &d->tintColor.x, 0);
args.setValue(DMT_SURFACE_RGBA, &d->tintColor.y, 1);
args.setValue(DMT_SURFACE_RGBA, &d->tintColor.z, 2);
args.setValue(DMT_SURFACE_RGBA, &d->opacity, 2);
break;
case DMU_COLOR_RED:
args.setValue(DMT_SURFACE_RGBA, &d->tintColor.x, 0);
break;
case DMU_COLOR_GREEN:
args.setValue(DMT_SURFACE_RGBA, &d->tintColor.y, 0);
break;
case DMU_COLOR_BLUE:
args.setValue(DMT_SURFACE_RGBA, &d->tintColor.z, 0);
break;
case DMU_ALPHA:
args.setValue(DMT_SURFACE_RGBA, &d->opacity, 0);
break;
case DMU_BLENDMODE:
args.setValue(DMT_SURFACE_BLENDMODE, &d->blendMode, 0);
break;
case DMU_FLAGS:
args.setValue(DMT_SURFACE_FLAGS, &d->flags, 0);
break;
default:
return MapElement::property(args);
}
return false; // Continue iteration.
}
int Surface::setProperty(DmuArgs const &args)
{
switch(args.prop)
{
case DMU_BLENDMODE: {
blendmode_t newBlendMode;
args.value(DMT_SURFACE_BLENDMODE, &newBlendMode, 0);
setBlendMode(newBlendMode);
break; }
case DMU_FLAGS:
args.value(DMT_SURFACE_FLAGS, &d->flags, 0);
break;
case DMU_COLOR: {
Vector3f newColor;
args.value(DMT_SURFACE_RGBA, &newColor.x, 0);
args.value(DMT_SURFACE_RGBA, &newColor.y, 1);
args.value(DMT_SURFACE_RGBA, &newColor.z, 2);
setTintColor(newColor);
break; }
case DMU_COLOR_RED: {
float newRed;
args.value(DMT_SURFACE_RGBA, &newRed, 0);
setTintRed(newRed);
break; }
case DMU_COLOR_GREEN: {
float newGreen;
args.value(DMT_SURFACE_RGBA, &newGreen, 0);
setTintGreen(newGreen);
break; }
case DMU_COLOR_BLUE: {
float newBlue;
args.value(DMT_SURFACE_RGBA, &newBlue, 0);
setTintBlue(newBlue);
break; }
case DMU_ALPHA: {
float newOpacity;
args.value(DMT_SURFACE_RGBA, &newOpacity, 0);
setOpacity(newOpacity);
break; }
case DMU_MATERIAL: {
Material *newMaterial;
args.value(DMT_SURFACE_MATERIAL, &newMaterial, 0);
setMaterial(newMaterial);
break; }
case DMU_OFFSET_X: {
float newOriginX;
args.value(DMT_SURFACE_OFFSET, &newOriginX, 0);
setMaterialOriginX(newOriginX);
break; }
case DMU_OFFSET_Y: {
float newOriginY;
args.value(DMT_SURFACE_OFFSET, &newOriginY, 0);
setMaterialOriginY(newOriginY);
break; }
case DMU_OFFSET_XY: {
Vector2f newOrigin = d->materialOrigin;
args.value(DMT_SURFACE_OFFSET, &newOrigin.x, 0);
args.value(DMT_SURFACE_OFFSET, &newOrigin.y, 1);
setMaterialOrigin(newOrigin);
break; }
default:
return MapElement::setProperty(args);
}
return false; // Continue iteration.
}