mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -04:00
Fix compiler errors and crashes with Assimp loader
This commit is contained in:
parent
efa8633cb0
commit
945d3c4035
@ -25,7 +25,6 @@
|
||||
#include "materialAttrib.h"
|
||||
#include "textureAttrib.h"
|
||||
#include "cullFaceAttrib.h"
|
||||
#include "lightNode.h"
|
||||
#include "ambientLight.h"
|
||||
#include "directionalLight.h"
|
||||
#include "spotlight.h"
|
||||
@ -570,12 +569,15 @@ load_light(const aiLight &light) {
|
||||
aiColor3D col;
|
||||
aiVector3D vec;
|
||||
|
||||
PT(LightNode) lnode;
|
||||
PT(PandaNode) lnode;
|
||||
|
||||
switch (light.mType) {
|
||||
case aiLightSource_DIRECTIONAL: {
|
||||
PT(DirectionalLight) dlight = new DirectionalLight(name);
|
||||
lnode = DCAST(LightNode, dlight);
|
||||
lnode = DCAST(PandaNode, dlight);
|
||||
|
||||
col = light.mColorDiffuse;
|
||||
dlight->set_color(LColor(col.r, col.g, col.b, 1));
|
||||
|
||||
col = light.mColorSpecular;
|
||||
dlight->set_specular_color(LColor(col.r, col.g, col.b, 1));
|
||||
@ -589,7 +591,10 @@ load_light(const aiLight &light) {
|
||||
|
||||
case aiLightSource_POINT: {
|
||||
PT(PointLight) plight = new PointLight(name);
|
||||
lnode = DCAST(LightNode, plight);
|
||||
lnode = DCAST(PandaNode, plight);
|
||||
|
||||
col = light.mColorDiffuse;
|
||||
plight->set_color(LColor(col.r, col.g, col.b, 1));
|
||||
|
||||
col = light.mColorSpecular;
|
||||
plight->set_specular_color(LColor(col.r, col.g, col.b, 1));
|
||||
@ -604,7 +609,10 @@ load_light(const aiLight &light) {
|
||||
|
||||
case aiLightSource_SPOT: {
|
||||
PT(Spotlight) plight = new Spotlight(name);
|
||||
lnode = DCAST(LightNode, plight);
|
||||
lnode = DCAST(PandaNode, plight);
|
||||
|
||||
col = light.mColorDiffuse;
|
||||
plight->set_color(LColor(col.r, col.g, col.b, 1));
|
||||
|
||||
col = light.mColorSpecular;
|
||||
plight->set_specular_color(LColor(col.r, col.g, col.b, 1));
|
||||
@ -630,15 +638,13 @@ load_light(const aiLight &light) {
|
||||
}
|
||||
|
||||
// If there's an ambient color, add it as ambient light.
|
||||
col = light.mColorAmbient;
|
||||
LVecBase4 ambient (col.r, col.g, col.b, 0);
|
||||
if (ambient != LVecBase4::zero()) {
|
||||
PT(AmbientLight) alight = new AmbientLight(name);
|
||||
col = light.mColorAmbient;
|
||||
alight->set_color(ambient);
|
||||
_root->add_child(alight);
|
||||
}
|
||||
|
||||
_root->add_child(lnode);
|
||||
col = light.mColorDiffuse;
|
||||
lnode->set_color(LColor(col.r, col.g, col.b, 1));
|
||||
}
|
||||
|
@ -78,6 +78,11 @@ Seek(size_t offset, aiOrigin origin) {
|
||||
case aiOrigin_END:
|
||||
_istream.seekg(offset, ios::end);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Keep compiler happy
|
||||
nassertr(false, AI_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (_istream.good()) {
|
||||
@ -105,4 +110,5 @@ Tell() const {
|
||||
size_t PandaIOStream::
|
||||
Write(const void *buffer, size_t size, size_t count) {
|
||||
nassertr(false, 0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -95,5 +95,6 @@ Open(const char *file, const char *mode) {
|
||||
|
||||
} else {
|
||||
nassertr(false, NULL); // Not implemented on purpose.
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
protected:
|
||||
INLINE bool attachStream(Assimp::LogStream*, unsigned int) {};
|
||||
INLINE bool detatchStream(Assimp::LogStream*, unsigned int) {};
|
||||
INLINE bool detatchStream(Assimp::LogStream*, unsigned int) {}; // sic
|
||||
|
||||
void OnDebug(const char *message);
|
||||
void OnError(const char *message);
|
||||
|
Loading…
x
Reference in New Issue
Block a user