mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fix lights for Windows
This commit is contained in:
parent
790cffef39
commit
9d5a0a521e
@ -22,6 +22,20 @@
|
|||||||
template<class Property, class NameClass>
|
template<class Property, class NameClass>
|
||||||
TypeHandle MultiTransition<Property, NameClass>::_type_handle;
|
TypeHandle MultiTransition<Property, NameClass>::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MultiTransition::SortByFirstOfPair function operator
|
||||||
|
// Access: Public
|
||||||
|
// Description: Implements the STL function object that sorts
|
||||||
|
// elements in the vector according to the first
|
||||||
|
// component of each element.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
template<class Property, class NameClass>
|
||||||
|
INLINE_GRAPH bool MultiTransition<Property, NameClass>::SortByFirstOfPair::
|
||||||
|
operator ()(const MultiTransition<Property, NameClass>::Element &a,
|
||||||
|
const MultiTransition<Property, NameClass>::Element &b) const {
|
||||||
|
return a.first < b.first;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MultiTransition::Constructor
|
// Function: MultiTransition::Constructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -139,7 +153,20 @@ get_default_dir() const {
|
|||||||
template<class Property, class NameClass>
|
template<class Property, class NameClass>
|
||||||
void MultiTransition<Property, NameClass>::
|
void MultiTransition<Property, NameClass>::
|
||||||
set_identity(const Property &property) {
|
set_identity(const Property &property) {
|
||||||
_properties[property] = TD_identity;
|
Properties::iterator pi;
|
||||||
|
for (pi = _properties.begin(); pi != _properties.end(); ++pi) {
|
||||||
|
if ((*pi).first == property) {
|
||||||
|
(*pi).second = TD_identity;
|
||||||
|
state_changed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It wasn't already on the list; append it.
|
||||||
|
_properties.push_back(Element(property, TD_identity));
|
||||||
|
|
||||||
|
// And now we need to re-sort the list.
|
||||||
|
sort(_properties.begin(), _properties.end(), SortByFirstOfPair());
|
||||||
state_changed();
|
state_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +180,20 @@ set_identity(const Property &property) {
|
|||||||
template<class Property, class NameClass>
|
template<class Property, class NameClass>
|
||||||
void MultiTransition<Property, NameClass>::
|
void MultiTransition<Property, NameClass>::
|
||||||
set_on(const Property &property) {
|
set_on(const Property &property) {
|
||||||
_properties[property] = TD_on;
|
Properties::iterator pi;
|
||||||
|
for (pi = _properties.begin(); pi != _properties.end(); ++pi) {
|
||||||
|
if ((*pi).first == property) {
|
||||||
|
(*pi).second = TD_on;
|
||||||
|
state_changed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It wasn't already on the list; append it.
|
||||||
|
_properties.push_back(Element(property, TD_on));
|
||||||
|
|
||||||
|
// And now we need to re-sort the list.
|
||||||
|
sort(_properties.begin(), _properties.end(), SortByFirstOfPair());
|
||||||
state_changed();
|
state_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +207,20 @@ set_on(const Property &property) {
|
|||||||
template<class Property, class NameClass>
|
template<class Property, class NameClass>
|
||||||
void MultiTransition<Property, NameClass>::
|
void MultiTransition<Property, NameClass>::
|
||||||
set_off(const Property &property) {
|
set_off(const Property &property) {
|
||||||
_properties[property] = TD_off;
|
Properties::iterator pi;
|
||||||
|
for (pi = _properties.begin(); pi != _properties.end(); ++pi) {
|
||||||
|
if ((*pi).first == property) {
|
||||||
|
(*pi).second = TD_off;
|
||||||
|
state_changed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It wasn't already on the list; append it.
|
||||||
|
_properties.push_back(Element(property, TD_off));
|
||||||
|
|
||||||
|
// And now we need to re-sort the list.
|
||||||
|
sort(_properties.begin(), _properties.end(), SortByFirstOfPair());
|
||||||
state_changed();
|
state_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,10 +234,11 @@ template<class Property, class NameClass>
|
|||||||
bool MultiTransition<Property, NameClass>::
|
bool MultiTransition<Property, NameClass>::
|
||||||
is_identity(const Property &property) const {
|
is_identity(const Property &property) const {
|
||||||
Properties::const_iterator pi;
|
Properties::const_iterator pi;
|
||||||
pi = _properties.find(property);
|
for (pi = _properties.begin(); pi != _properties.end(); ++pi) {
|
||||||
if (pi != _properties.end()) {
|
if ((*pi).first == property) {
|
||||||
return (*pi).second == TD_identity;
|
return (*pi).second == TD_identity;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The property is not mentioned. It's implicitly identity only if
|
// The property is not mentioned. It's implicitly identity only if
|
||||||
// the default_dir flag is identity.
|
// the default_dir flag is identity.
|
||||||
@ -201,13 +255,14 @@ template<class Property, class NameClass>
|
|||||||
bool MultiTransition<Property, NameClass>::
|
bool MultiTransition<Property, NameClass>::
|
||||||
is_on(const Property &property) const {
|
is_on(const Property &property) const {
|
||||||
Properties::const_iterator pi;
|
Properties::const_iterator pi;
|
||||||
pi = _properties.find(property);
|
for (pi = _properties.begin(); pi != _properties.end(); ++pi) {
|
||||||
if (pi != _properties.end()) {
|
if ((*pi).first == property) {
|
||||||
return (*pi).second == TD_on;
|
return (*pi).second == TD_on;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The property is not mentioned. It's implicitly 'on' only if the
|
// The property is not mentioned. It's implicitly on only if
|
||||||
// default_dir flag is TD_on.
|
// the default_dir flag is on.
|
||||||
return (_default_dir == TD_on);
|
return (_default_dir == TD_on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,13 +276,14 @@ template<class Property, class NameClass>
|
|||||||
bool MultiTransition<Property, NameClass>::
|
bool MultiTransition<Property, NameClass>::
|
||||||
is_off(const Property &property) const {
|
is_off(const Property &property) const {
|
||||||
Properties::const_iterator pi;
|
Properties::const_iterator pi;
|
||||||
pi = _properties.find(property);
|
for (pi = _properties.begin(); pi != _properties.end(); ++pi) {
|
||||||
if (pi != _properties.end()) {
|
if ((*pi).first == property) {
|
||||||
return (*pi).second == TD_off;
|
return (*pi).second == TD_off;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The property is not mentioned. It's implicitly 'off' only if the
|
// The property is not mentioned. It's implicitly off only if
|
||||||
// default_dir flag is TD_off.
|
// the default_dir flag is off.
|
||||||
return (_default_dir == TD_off);
|
return (_default_dir == TD_off);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +347,7 @@ compose(const NodeTransition *other) const {
|
|||||||
|
|
||||||
dmap_compose(_properties.begin(), _properties.end(),
|
dmap_compose(_properties.begin(), _properties.end(),
|
||||||
ot->_properties.begin(), ot->_properties.end(),
|
ot->_properties.begin(), ot->_properties.end(),
|
||||||
inserter(result->_properties, result->_properties.begin()));
|
back_inserter(result->_properties));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -315,7 +371,8 @@ invert() const {
|
|||||||
result->_default_dir = TD_identity;
|
result->_default_dir = TD_identity;
|
||||||
|
|
||||||
dmap_invert(_properties.begin(), _properties.end(),
|
dmap_invert(_properties.begin(), _properties.end(),
|
||||||
inserter(result->_properties, result->_properties.begin()));
|
back_inserter(result->_properties),
|
||||||
|
(Element *)NULL);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
#ifndef MULTITRANSITION_H
|
#ifndef MULTITRANSITION_H
|
||||||
#define MULTITRANSITION_H
|
#define MULTITRANSITION_H
|
||||||
|
|
||||||
#include <pandabase.h>
|
#include "pandabase.h"
|
||||||
|
|
||||||
#include "nodeTransition.h"
|
#include "nodeTransition.h"
|
||||||
#include "transitionDirection.h"
|
#include "transitionDirection.h"
|
||||||
#include "multiTransitionHelpers.h"
|
#include "multiTransitionHelpers.h"
|
||||||
|
|
||||||
#include <indent.h>
|
#include "indent.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : MultiTransition
|
// Class : MultiTransition
|
||||||
@ -52,7 +54,18 @@
|
|||||||
template<class Property, class NameClass>
|
template<class Property, class NameClass>
|
||||||
class MultiTransition : public NodeTransition {
|
class MultiTransition : public NodeTransition {
|
||||||
private:
|
private:
|
||||||
typedef pmap<Property, TransitionDirection> Properties;
|
typedef pair<Property, TransitionDirection> Element;
|
||||||
|
|
||||||
|
// This has to be a vector and not a map, so we can safely access
|
||||||
|
// the iterators outside of PANDA.DLL.
|
||||||
|
typedef pvector<Element> Properties;
|
||||||
|
|
||||||
|
// We use this as an STL function object for sorting the vector in
|
||||||
|
// order by its property.
|
||||||
|
class SortByFirstOfPair {
|
||||||
|
public:
|
||||||
|
INLINE_GRAPH bool operator ()(const Element &a, const Element &b) const;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MultiTransition();
|
MultiTransition();
|
||||||
@ -106,8 +119,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// These functions and typedefs allow one to peruse all of the
|
// These functions and typedefs allow one to peruse all of the
|
||||||
// Properties in the transition. Beware! It is not safe to use
|
// Properties in the transition.
|
||||||
// this interface outside of PANDA.DLL.
|
|
||||||
typedef Properties::const_iterator iterator;
|
typedef Properties::const_iterator iterator;
|
||||||
typedef Properties::const_iterator const_iterator;
|
typedef Properties::const_iterator const_iterator;
|
||||||
typedef Properties::value_type value_type;
|
typedef Properties::value_type value_type;
|
||||||
|
@ -131,26 +131,24 @@ dmap_invert_compose(InputIterator1 first1, InputIterator1 last1,
|
|||||||
// input. Guarantees that the new list will have
|
// input. Guarantees that the new list will have
|
||||||
// exactly the same length as the input list.
|
// exactly the same length as the input list.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
template<class InputIterator, class OutputIterator>
|
template<class InputIterator, class OutputIterator, class ValueType>
|
||||||
OutputIterator
|
OutputIterator
|
||||||
dmap_invert(InputIterator first, InputIterator last,
|
dmap_invert(InputIterator first, InputIterator last,
|
||||||
OutputIterator result) {
|
OutputIterator result, ValueType *) {
|
||||||
typedef TYPENAME InputIterator::value_type OutputType;
|
|
||||||
|
|
||||||
while (first != last) {
|
while (first != last) {
|
||||||
switch ((*first).second) {
|
switch ((*first).second) {
|
||||||
case TD_identity:
|
case TD_identity:
|
||||||
(*result) = OutputType((*first).first, TD_identity);
|
(*result) = ValueType((*first).first, TD_identity);
|
||||||
++result;
|
++result;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TD_on:
|
case TD_on:
|
||||||
(*result) = OutputType((*first).first, TD_off);
|
(*result) = ValueType((*first).first, TD_off);
|
||||||
++result;
|
++result;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TD_off:
|
case TD_off:
|
||||||
(*result) = OutputType((*first).first, TD_on);
|
(*result) = ValueType((*first).first, TD_on);
|
||||||
++result;
|
++result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,10 @@ dmap_invert_compose(InputIterator1 first1, InputIterator1 last1,
|
|||||||
// input. Guarantees that the new list will have
|
// input. Guarantees that the new list will have
|
||||||
// exactly the same length as the input list.
|
// exactly the same length as the input list.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
template<class InputIterator, class OutputIterator>
|
template<class InputIterator, class OutputIterator, class ValueType>
|
||||||
OutputIterator
|
OutputIterator
|
||||||
dmap_invert(InputIterator first, InputIterator last,
|
dmap_invert(InputIterator first, InputIterator last,
|
||||||
OutputIterator result);
|
OutputIterator result, ValueType *);
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -55,6 +55,15 @@ public:
|
|||||||
virtual NodeTransition *make_identity() const;
|
virtual NodeTransition *make_identity() const;
|
||||||
virtual NodeTransition *make_initial() const;
|
virtual NodeTransition *make_initial() const;
|
||||||
|
|
||||||
|
#ifdef CPPPARSER
|
||||||
|
// Interrogate seems to have difficulty figuring out that we do
|
||||||
|
// implement this pure virtual function properly in MultiTransition.
|
||||||
|
// For now, we'll pretend for interrogate's sake that it's also
|
||||||
|
// implemented here, just so interrogate doesn't believe the class
|
||||||
|
// is abstract.
|
||||||
|
virtual NodeAttribute *apply(const NodeAttribute *attrib) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void issue(GraphicsStateGuardianBase *gsgbase);
|
virtual void issue(GraphicsStateGuardianBase *gsgbase);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user