| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#pragma once |
| 18 |
|
| 19 |
#include "Lighting.h" |
| 20 |
#include "Properties.h" |
| 21 |
|
| 22 |
namespace android { |
| 23 |
namespace uirenderer { |
| 24 |
|
| 25 |
class LightingInfo { |
| 26 |
public: |
| 27 |
|
| 28 |
static float getLightRadius() { |
| 29 |
if (CC_UNLIKELY(Properties::overrideLightRadius > 0)) { |
| 30 |
return Properties::overrideLightRadius; |
| 31 |
} |
| 32 |
return mLightRadius; |
| 33 |
} |
| 34 |
|
| 35 |
static uint8_t getAmbientShadowAlpha() { |
| 36 |
if (CC_UNLIKELY(Properties::overrideAmbientShadowStrength >= 0)) { |
| 37 |
return Properties::overrideAmbientShadowStrength; |
| 38 |
} |
| 39 |
return mAmbientShadowAlpha; |
| 40 |
} |
| 41 |
|
| 42 |
static uint8_t getSpotShadowAlpha() { |
| 43 |
if (CC_UNLIKELY(Properties::overrideSpotShadowStrength >= 0)) { |
| 44 |
return Properties::overrideSpotShadowStrength; |
| 45 |
} |
| 46 |
return mSpotShadowAlpha; |
| 47 |
} |
| 48 |
|
| 49 |
static Vector3 getLightCenter() { |
| 50 |
if (CC_UNLIKELY(Properties::overrideLightPosY > 0 || Properties::overrideLightPosZ > 0)) { |
| 51 |
Vector3 adjustedLightCenter = mLightCenter; |
| 52 |
if (CC_UNLIKELY(Properties::overrideLightPosY > 0)) { |
| 53 |
|
| 54 |
adjustedLightCenter.y = -Properties::overrideLightPosY; |
| 55 |
} |
| 56 |
if (CC_UNLIKELY(Properties::overrideLightPosZ > 0)) { |
| 57 |
adjustedLightCenter.z = Properties::overrideLightPosZ; |
| 58 |
} |
| 59 |
return adjustedLightCenter; |
| 60 |
} |
| 61 |
return mLightCenter; |
| 62 |
} |
| 63 |
|
| 64 |
static Vector3 getLightCenterRaw() { |
| 65 |
return mLightCenter; |
| 66 |
} |
| 67 |
|
| 68 |
static void setLightCenterRaw(const Vector3& lightCenter) { |
| 69 |
mLightCenter = lightCenter; |
| 70 |
} |
| 71 |
|
| 72 |
static void updateLighting(const LightGeometry& lightGeometry, const LightInfo& lightInfo) { |
| 73 |
mLightRadius = lightGeometry.radius; |
| 74 |
mAmbientShadowAlpha = lightInfo.ambientShadowAlpha; |
| 75 |
mSpotShadowAlpha = lightInfo.spotShadowAlpha; |
| 76 |
mLightCenter = lightGeometry.center; |
| 77 |
} |
| 78 |
private: |
| 79 |
static float mLightRadius; |
| 80 |
static uint8_t mAmbientShadowAlpha; |
| 81 |
static uint8_t mSpotShadowAlpha; |
| 82 |
static Vector3 mLightCenter; |
| 83 |
}; |
| 84 |
|
| 85 |
} |
| 86 |
} |